Put this in a login page, i.e. login.php
Credit: webdeveloper forums, pyro's post
<form method="post" action="passwordreader.php">
<table>
<tr><td><b class=rng>Username:</b></td><td> </td><td><input type="text" name="username"></td></tr>
<tr><td><b class=rng>Password:</b></td><td> </td><td><input type="password" name="password"></td></tr>
<tr><td colspan="3" align="center"><input type="submit" value=" Submit "></td></tr>
</table>
</form>
Name this file "passwordreader.php" and put in it:
<?PHP
# Change the below lines to the results that makepass.php gave you
#
$user = 'yourencryptedusername';
$pass = 'yourencryptedpassword';
#
# Change the above lines to the results that makepass.php gave you
if(md5($_POST['username']) == $user && md5($_POST['password']) == $pass)
{
setcookie ("verified", true);
header ("Location:<a href="http://www.yoursite.com/dir/page.htm" target="_blank">[url]http://www.yoursite.com/dir/page.htm[/url]</a>");
}
else
{
echo ("Incorrect Password");
}
?>
Name this protect.php and put this in it:
<?PHP
# Protect page from being called directly from web browser
$back = "<form><input type='button' value='< Back' onclick='history.back()'></form>";
$acc_denied = "<h3>Access Denied</h3>".$back; # you could add a link to where users can login here...
if (!isset($_COOKIE["verified"])) { die($acc_denied); }
?>
On the top of all pages you want "secured" put:
<? include_once("protect.php"); ?>
And to make the password for $user and &pass name this makepass.php and put in it:
<?PHP
if ($_POST['showvalues'])
{
echo 'User: ' . md5($_POST['username']);
echo '<br>Password: ' . md5($_POST['password']);
}
?>
<form method="post" action="makepass.php">
<table>
<tr><td><b class=rng>Username:</b></td><td> </td><td><input type="text" name="username"></td></tr>
<tr><td><b class=rng>Password:</b></td><td> </td><td><input type="text" name="password"></td></tr>
<tr><td colspan="3" align="center"><input type="submit" value=" Submit " name="showvalues"></td></tr>
</table>
</form>
Hope this helps you.