You can also use PHP for password protected pages.
PHP Code:
<?php
$form = "<table>
<tr>
<td align='center' bgcolor='lightblue'>
<font face='verdana' size='1'><b>This page is password protected!</b></td></tr>
<tr>
<td align='center'><form method='post' action='protected.php'>
<input name='password' type='password' id='password' maxlength='15'></td></tr>
<tr><td align='center'>
<input type='submit' name='Submit' value='Unlock this page!'></form></td></tr>
</table></center>";
echo "$form";
?>
PHP Code:
<?PHP
$setpassword = "PASSWORD";
// Change the password above
$password = $_POST['password'];
if ($password == $setpassword)
{
echo "Access granted.";
}
else
{
echo "Access denied.";
}
?>
Also another different way is:
PHP Code:
<?
//part 1
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"Your Password.\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}
//part 2
else if(($PHP_AUTH_USER=="youruser") && ($PHP_AUTH_PW=="yourpassword"))
{
echo "Authenticated!";
//place the code for the whole user page in here
//you can also set up a redirect to the user page if you want
}
//part 3
else
{
echo "Login Failed";
//fail try again
}
?>
Bookmarks