以下是我用于HTTP身份验证的代码。我面临的问题是我无法获得用户名和密码中发布的值。请告诉我如何解决这个问题?
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (stripos($actual_link, 'rate') !== false)
{
$valid_passwords = "abcd";
$valid_users = "loanq";
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if ($user != $valid_users || $pass != $valid_passwords)
{
$validated = false;
}
else
{
$validated = true;
}
if (!$validated) {
header('WWW-Authenticate: Basic realm="Authenticate Yourself"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}