对目录进行密码保护的PHP代码
2006年02月15日 00:50 • 查看 3,293 次 • 打印本文下面的代码可以对你的目录进行保护:
< ?
//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 "Faiiiiiiiil";
//fail try again
}
?>
评论
发表评论