<? //这是文件auth.inc /*验证用户身份信息*/ if(!isset($PHP_AUTH_USER)) { header("WWW-Authenticate:Basic realm=\"访问权限验证\""); header("HTTP/1.0 401 Unauthorized"); echo "您没有输入用户名,您无权登录到本站!"; header("WWW-Authenticate:Basic realm=\"访问权限验证\""); header("HTTP/1.0 401 Unauthorized"); exit(); } /*连接数据库*/ else { include('config.php'); /*查询用户是否存在*/ $query1="select password,enable from adminaccess where username='$PHP_AUTH_USER' "; $result=mysql_query($query1); if(!$result) { header("WWW-Authenticate:Basic realm=\"身份验证功能\""); header("HTTP/1.0 401 Unauthorized"); echo "身份验证失败,您没有在本站注册!"; header("WWW-Authenticate:Basic realm=\"身份验证功能\""); header("HTTP/1.0 401 Unauthorized"); exit(); } else { $row=mysql_fetch_array($result); $password = $row[0]; $enable = $row[1]; if($enable==0) {echo "你没有访问权限"; header("WWW-Authenticate:Basic realm=\"身份验证功能\""); header("HTTP/1.0 401 Unauthorized"); exit();} else if ($password!=$PHP_AUTH_PW) { header("WWW-Authenticate:Basic realm=\"身份验证功能\""); header("HTTP/1.0 401 Unauthorized"); echo "身份验证失败,您无权登录到本站!"; header("WWW-Authenticate:Basic realm=\"身份验证功能\""); header("HTTP/1.0 401 Unauthorized"); exit(); } } } ?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货