Jump to content

PHP login system script help...


Rufus65

Recommended Posts

I am a horrible coder, i can only read a little bit of HTML but even that's stretching it. I have 2 pieces of code currently that i might possibly need merged and i can't do it without one code being completely changed into something that won't work. First of i'll explain my source codes. I went to Evolt.org :http://evolt.org/node/60384/: cause they had a pre-made PHP Login System script that i thought would be easy to integrate into my site. Here's the code i have currently in my index.html file that makes the login system look pretty [without the sign up button]:

<!--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="images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
				<br class="spacer" />
			</form>
		</div>
		<!--Login Area Ends -->
	</div>
	<!--Login Background Ends -->

 

Now here's the code i need transfered and merged into the code above so i can keep my login system the way it is:

<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<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>]   "
       ."[<a href=\"useredit.php\">Edit Account</a>]   ";
   if($session->isAdmin()){
      echo "[<a href=\"admin/admin.php\">Admin Center</a>]   ";
   }
   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     
<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>


</body>
</html>

 

now i went to my web hostings forums to see what they could do to help but all they gave me was this code that doesn't seem to work and is missing the username box:

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<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>]   "
       ."[<a href=\"useredit.php\">Edit Account</a>]   ";
   if($session->isAdmin()){
      echo "[<a href=\"admin/admin.php\">Admin Center</a>]   ";
   }
   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     
<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>
</body>
</html>

 

i have no clue what i'm doing at this point, all i want is to have a nice looking login system. I have the datatables.sql file and the PHPMyAdmin database [provided by my hosting service] taken care of, i just need the links made between all the PHP code and the layout style i already have made. Here's the beginning section of my home page that contains the entire header [including the login boxes] and all the way to the sign up button:

 

<!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" /></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="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>
				<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="images/login-btn.gif" class="login-btn" alt="Login" title="Login" />
				<br class="spacer" />
			</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="#" 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 -->

 

Also if it helps anymore , i am using Adobe Dreamweaver & Photoshop CS3. And when i get the website up and running ill try to use Adobe Contribute CS3 as well.

 

Any help would be very much appreciated. Thank you very much. ;D ;D ;D

Link to comment
https://forums.phpfreaks.com/topic/164236-php-login-system-script-help/
Share on other sites

  • 4 weeks later...

I know it’s been a while since your last login, but I recently wrote an article explaining how to set up jpmaster77's login system.  Take a look: http://ivannovak.com/jpmaster77s-login-system-tutorial/

 

I'll try to answer any questions you may have.

 

Thanks!

-Ivan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.