你用的PHP版本是多少。
4.1.0以后register global = off
这样取不到变量
取得变量用$_SERVER['PHP_AUTH_USER']和$_SERVER['PHP_AUTH_PW];
或者将php.ini中register global 设为 on
4.1.0以后register global = off
这样取不到变量
取得变量用$_SERVER['PHP_AUTH_USER']和$_SERVER['PHP_AUTH_PW];
或者将php.ini中register global 设为 on
if(!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate:Basic realm=\"访问权限验证\"");
header("HTTP/1.0 401 Unauthorized");
echo "<script>alert('请注册/登陆后购物!');top.location.href='index.php';</script>";
}
/*连接数据库*/
else
{
include('conn.php');
/*查询用户是否存在*/
$query1 = "select password,enable from access where username='$PHP_AUTH_USER' ";
$result = @mysql_query($query1);
if(!$result)
{
header("WWW-Authenticate:Basic realm=\"身份验证功能\"");
header("HTTP/1.0 401 Unauthorized");
echo "<script>alert('请注册/登陆后购物!');top.location.href='index.php';</script>";
}
else
{
$row = @mysql_fetch_array($result);
$password = $row[0];
$enable = $row[1];
if($enable==0)
{
header("WWW-Authenticate:Basic realm=\"身份验证功能\"");
header("HTTP/1.0 401 Unauthorized");
echo "<script>alert('请注册/登陆后购物!');top.location.href='index.php';</script>";
}
else if ($password!=$PHP_AUTH_PW)
{
header("WWW-Authenticate:Basic realm=\"身份验证功能\"");
header("HTTP/1.0 401 Unauthorized");
echo "<script>alert('请注册/登陆后购物!');top.location.href='index.php';</script>";
}
}
}
?>