This tutorial will help you learn how to password protect your file quickly and easily in a few lines of code.
<?
//part 1
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"Spoono Password.\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}
//part 2
else if(($PHP_AUTH_USER=="spoono") && ($PHP_AUTH_PW=="spoono"))
{
echo "You got in...";
//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 "<html><body bgcolor=ffffcc>Faiiiiiiiil";
//fail try again
}
?>