导航

php简单的server登陆验证

Posted on 2011-08-21 17:25  C'est la vie  阅读(337)  评论(0编辑  收藏  举报
if (! isset ( $_SERVER ['PHP_AUTH_USER'] ) || ! isset ( $_SERVER ['PHP_AUTH_PW'] ) || $_SERVER ['PHP_AUTH_USER'] != 'admin' || $_SERVER ['PHP_AUTH_PW'] != '123456') {
header ( 'WWW-Authenticate: Basic realm="My Realm"' );
header ( 'HTTP/1.0 401 Unauthorized' );
echo '用户名或密码不正确';
exit ();
}