Stumped on PHP Authentication
Posted: Mon Jan 31, 2005 2:15 am
Hi. I'm totally stumped on why this code doesn't work on my server (hosted by POWWEB). When the bottom is executed, my user/pass dialog box never drops unless I hit cancel. Shouldn't it drop out from authenticating after I press the OK button followed by printing the name and password previously entered? I'm going through this exercise only because I consistently fail to evaluate $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'].
Can someone give me a hand pleaes?
Can someone give me a hand pleaes?
Code: Select all
if (!isset($_SERVERї'PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVERї'PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVERї'PHP_AUTH_PW']} as your password.</p>";
}