I have a simple http authentication code:
<?php
if (!isset($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\n";
exit;
} else {
echo "<p>Hello $PHP_AUTH_USER.</p>";
echo "<p>You entered $PHP_AUTH_PW as your password.</p>";
}
?>
That is copy and paste from web site so can't be wrong. So the problem is, the authentication box keeps popping out. By right if I keep in the username it should not appear already right. What could be the problem?
And I need to <?;ob_start();?> at the top of the page before the authentication works. Is it suppose to be like that?