| 
		
			| Password Page [message #116097] | Wed, 22 September 2004 16:28   |  
			| 
				
				|  |  Madtone Messages: 713
 Registered: February 2003
 Location: United Kingdom
 
	Karma: 
 | Colonel |  |  |  
	| Ok, heres a basic page for you, name it index.php 
 
 
<?
//the password
$the_pass = "pass123";
if ($action == "login") {
   if ($_POST['pass'] == $the_pass) {
   
   //set them as logged in
   $_SESSION['pass'] = $the_pass;
   }else{
   echo "wrong password, please hit back";
   }
}else{
   //checks if you have typed in the pass
   if ($_SESSION['pass'] == $the_pass) {
   
   //your page content goes here
   echo "
   <html>
   <head>
   <title>my page - members section</title>
   </head>
   <body>
     welocme to members section
    </body>
   </html>
   ";
   }else{
   //login page goes here
   echo "
   <html>
   <head>
   <title>my page - login</title>
   </head>
   <body>
   <form action='index.php?action=login' method='post'>
   Username:<br>
   <input type='text' name='pass'>
   <p></p>
   <input type='submit' name='submit' value='Login'>
   </form>
   </body>
   </html>
   ";
   }
}
?>
 I just wrote this from scratch just now, so they're might be errors, basicly this is just a quick script that checks if the pass session is registered and if it is, does the pass match the supplied pass.
 
 If you want something more secure i suggest mySQL, sessions and MD5 encryption.
 
 If you would like me to code you a proper login and user management system i have low prices.
 
 Hope this helps
   
 
   [Updated on: Wed, 22 September 2004 16:33] Report message to a moderator |  
	|  |  |