php
security server-variables basic-authentication username password authentication-success www-authenticate http-1-0-401-unauthorized header
Published on January 26, 2024By DeveloperBreeze
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($username == 'admin' && $password == 'secret') {
echo 'Authentication successful.';
} else {
header('WWW-Authenticate: Basic realm="Restricted Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authentication failed.';
exit;
}
Comments
Please log in to leave a comment.