I am using the following PHP Authentication script for a site, but when I enter the user and password, the script won't accept them as correct (TEST/TEST1) and it always reloads the user/pass prompt (login function).
Here is my script.
function login()
{
header('WWW-Authenticate: Basic realm="Acceso restringido."');
header('HTTP/1.0 401 Unauthorized');
echo "Acceso restringido.
";
exit;
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
login();
}
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':' , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
// open a user/pass prompt
if (!isset($_SERVER['PHP_AUTH_USER'])) {
login();
} else {
if ($_SERVER['PHP_AUTH_USER'] == 'TEST' && $_SERVER['PHP_AUTH_PW'] == 'TEST1') {
} else {
login();
}
}