working with a PHP login system script...

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
:dunno:I am not at all a good coder to say for this problem, just warning you now.:nuts:

I was browsing Google for a nice PHP based login script for my site and i found Evolt.org.:eek4: I read through the page and it had some very good reviews/comments and everything, but i need to know these main things:

1] how do i integrate them with my site?? :dunno:(Really need help at this point, i'm freaking confused...)

2] where do i put the files so i can upload them on the server correctly?

here's a link to the files the site was talking about and that i have to work with.
Or you can download the attachment: :lockd::Login System v.2.0 PHP Scripts::lockd:

:hsugh:Any help at all would be much appreciated.:fingersx:
 

Attachments

  • Login_System_v.2.0.zip
    22.8 KB · Views: 12
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Your files should go in /home/{your user name}/public_html

you need to unzip the files. Using the MySQL databases wizard, create a database and user (call them whatever you want. note however, that uses and databases will start with your cpanel user name, ie "db" is really "garrett_db" and "user" is really "garrett_user". this is done automatically for you)

Now, using PHPMyAdmin, you need to select your database, then use IMPORT to import the datatables.sql file.

Integration is through main.php. You need to provide a link to this file so your users can log in. You can access a user's information using the $_SESSION superglobal, IE $_SESSION['username'].
 

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
thanks, but i don't think i went into much detail, i got the datatables.sql imported and that's running fine, but how do i make the link between my already made username and password boxes and the main.php file as well as the sign up button while still keeping my style the same?
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
The trick will be to modify the code from main.php. Make sure you include('session.php');

Code:
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); >"></td>
<td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>">
</td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo checked"; } ?>>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td>
<td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

You'll have to change your inputs to look like this.
 
Last edited:

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
Okay, here's what I have right now the design style code in my index.html file:
Code:
<!--Login Background Starts -->
<div id="login-bg">
<!--Login Area Starts -->
<div id="login-area">
<form action="" method="post" name="Login" id="Login">
<label>Members Login:</label>
<input name="username" type="text" id="username" value="username" maxlength="30" />
<input name="pass" type="password" id="pass" value="password" maxlength="30" />
<input type="image" src="http://forums.x10hosting.com/images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
<br class="spacer" />
</form>
</div>
<!--Login Area Ends -->
</div>
<!--Login Background Ends -->

and here's the code i need to merge with to make the link possible while keeping my design the same:

Code:
<table>
<tr><td>


<?
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b> <br><br>"
       ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
       ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
   if($session->isAdmin()){
      echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
   }
   echo "[<a href=\"process.php\">Logout</a>]";
}
else{
?>

<h1>Login</h1>
<?
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me &nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>
Not registered? <a href="register.php">Sign-Up</a></td>
</tr>
</table>
</form>

<?
}

/**
 * Just a little page footer, tells how many registered members
 * there are, how many users currently logged in and viewing site,
 * and how many guests viewing site. Active users are displayed,
 * with link to their user information.
 */
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>


</td></tr>
</table>

i have no clue on how to do any of this... so im getting really confused now:dunno:. basically your telling me to establish a link with the table or the individual boxes [i.e. username & password box and the login and the sign up box] with the main.php file? if so then i need help merging or whatever it is between those two elements. the code you posted i put into dreamweaver and it looks very similar to my main.php only it doesn't have the password fields or the login label, so i do know we should be on the same page...
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
I think I successfully merged the two parts of the code for you:

Code:
<table>
<tr><td>


<?
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b> <br><br>"
       ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
       ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
   if($session->isAdmin()){
      echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
   }
   echo "[<a href=\"process.php\">Logout</a>]";
}
else{
?>

<h1>Login</h1>
<?
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<!--Login Background Starts -->
<div id="login-bg">
<!--Login Area Starts -->
<div id="login-area">
<form action="process.php" method="POST">
Username:<input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"><? echo $form->error("user"); ?>
Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"><? echo $form->error("pass"); ?>
<input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me &nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="image" src="http://forums.x10hosting.com/images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
<br class="spacer" />
<font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font>
Not registered? <a href="register.php">Sign-Up</a>
</form>
</div>
<!--Login Area Ends -->
</div>
<!--Login Background Ends -->
</form>

<?
}

/**
 * Just a little page footer, tells how many registered members
 * there are, how many users currently logged in and viewing site,
 * and how many guests viewing site. Active users are displayed,
 * with link to their user information.
 */
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>


</td></tr>
</table>

You may have to tweak it a little. I'm tired and I don't have the entire page to look at ;)

Nice buckethead picture, btw :biggrin:
 

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
thanks, buckethead's a great guitar player.

anyways, i tried your new code and i mangled with it, but i still couldn't get it to work, i now understand how to establish the links, but i don't know how to link the username and password boxes and login picture as well. I got the sign up picture linked to the register.php script but i'm still messing up the links with the usename and password boxes. Here's the code for my entire header all the way up to my sign up button. i'll let you take a look at that and we can go from there...

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CYK Studios | Home</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
	color: #FCF7CC;
	font-weight: bold;
	font-size: x-small;
}
.style2 {color: #4B1A15}
-->
</style>
</head>

<body>
<!--Header Background Part Starts -->
<div id="header-bg">
	<!--Header Contant Part Starts -->
	<div id="header">
		<a href="index.html" target="_parent"><img src="http://forums.x10hosting.com/images/logo.gif" alt="CYK Studios" name="logo" width="281" height="62" class="logo" id="logo" title="CYK Studios" /></a>
		<!--Login Background Starts -->
<div id="login-bg">
			<!--Login Area Starts -->
			<div id="login-area">
				<form action="" method="post" name="Login" id="Login">
					<label>Members Login:</label>
					<div align="center">
					  <input name="username" type="text" id="username" value="username" maxlength="30" />
					  <input name="pass" type="password" id="pass" value="password" maxlength="30" />
					  <input type="image" src="http://forums.x10hosting.com/images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
					  <br class="spacer" />
					  <span class="style1"><span class="style2">______________________</span>Remember Me | <a href="forgotpass.php">Forgot Password?</a></span></div>
			  </form>
			</div>
			<!--Login Area Ends -->
		</div>
		<!--Login Background Ends -->
		<br class="spacer" />
	</div>
  <!--Header Contant Part Ends -->
</div>
<!--Header Background Part Ends -->
<!--Navigation Background Part Starts -->
<div id="navigation-bg">
	<!--Navigation Part Starts -->
	<div id="navigation">
		<ul class="mainMenu">
			<li><a href="index.html" class="selectMenu">Home</a></li>
			<li><a href="videos.html">Videos</a></li>
		  <li><a href="#">Archives</a></li>
			<li><a href="#">Forums</a></li>
			<li><a href="#">Podcasts</a></li>
			<li><a href="#">Downloads</a></li>
			<li class="noBg"><a href="#">Contact Us</a></li>
		</ul>
		<a href="register.php" class="signup"></a>
	  <br class="spacer" />
		<ul class="subNav">
			<li class="noBg"></li>
		  <li></li>
		  <li></li>
		  <li></li>
		  <li></li>
		  <li></li>
		  <li></li>
		  <li></li>
	  </ul>
		<br class="spacer" />
	</div>
	<!--Navigation Part Ends -->
</div>
<!--Navigation Background Part Ends -->

P.S. Thanks for all the help you've given me, i really appreciate it. :biggrin: :biggrin: :biggrin:
 
Last edited:

espfutbol98

New Member
Messages
200
Reaction score
2
Points
0
I'm not exactly sure what your problem is but when you integrate scripts with forms, the only important things are: you must have the "name", it must be the same type of input, and within a proper "form", and that's really all. "Class" and "id" are mostly for css. Hope that helps.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Ah, you can't change the name attribute of the inputs or you will break the link. Make sure you copy them exactly from the code given in main.php. I'm sorry if I copied it wrong, like I said, I was really tired :p
 

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
So what exactly do i copy from the main.php? and where do i paste it in?

Here's all i'm trying to do. This is a picture of my header containing the members login section along with the signup button. I don't care if i use the same PHP code i have now, all i want is some sort of PHP code that will allow me to make this login section functioning and stay this way.
 

Attachments

  • headerpic.bmp
    228.9 KB · Views: 44
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
You're fine with what you have, you just need to make a little change:

Code:
<input type="text" name="username" <!-- this is wrong, this is your own code -->
<input type="text" name="user" <!-- this is right, this is what is in main.php -->
 

rufussweetwater

New Member
Messages
56
Reaction score
0
Points
0
okay i fixed that, but now what? I am trying to link the main.php file but I end up getting a bunch of visible code on the WYSIWYG design board. also I changed the login button to link it but I lost my picture and now I just have a brown box with the word 'login' and no picture or CSS is kicking in. heres the code i worked on:

Code:
<!--Login Area Starts -->
			<div id="login-area">
				<form action="process.php" method="post" name="Login" id="Login">
					<label>Members Login:</label>
					<div align="center">
					  <input name="user" type="text" id="user" value="<? echo $form->value("user"); ?>" maxlength="32" />
					  <? echo $form->error("user"); ?>
					  <input name="pass" type="password" id="pass" value="<? echo $form->value("pass"); ?>" maxlength="32" />
					  <? echo $form->error("pass"); ?>
					  <input type="submit" src="http://forums.x10hosting.com/images/login-btn.gif" value="Login"  class="login-btn" alt="Login" title="Login" />
					  <br class="spacer" />
				  <span class="style1"><span class="style2"><?
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b> <br><br>"
       ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
       ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
   if($session->isAdmin()){
      echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
   }
   echo "[<a href=\"process.php\">Logout</a>]";
}
else{
?></span><?
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?> | Remember Me | <a href="forgotpass.php">Forgot Password?</a></span></div>
			  </form>
			</div>
			<!--Login Area Ends -->

also when i hit login it just opens up main.php in text form on my web browser and does nothing, along with all my other buttons...
 
Last edited:
Top