HTTP authentication
| From: | Varsha Agarwal | Date: | Wed, 10 Jul 2002 20:30:14 +0000 |
| Subject: | HTTP authentication | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-106947@lists.php.net to get a copy of this message | ||
Hi,
I am reading HTTP authentication in php manual. It
does not explain it from the basics of it. Can anyone
tell me what exactly will the output of the following
code? I thought it will ask some user name and
password thing but it just displays me the string
"text to send if user hits cancel".
This is the code
<?php
header("WWW-Authenticate: Basic realm=\"My
Realm\"");
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\n";
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as
your password.</p>";
}
?>
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com