HTTP authentication with PHP
| From: | Linda Lin | Date: | Sun, 02 Jul 2000 03:12:49 +0000 |
| Subject: | HTTP authentication with PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4332@lists.php.net to get a copy of this message | ||
Hi,
I am a beginner on PHP. I tried the following code,
expecting a small pop-up window allowing me to enter
the user name and password. But nothing showed up,
except a message of "Text to send if user hits Cancel
button". Could anyone give me some suggestiones on how
to fix it?
Thanks a lot,
Linda
1
2 <?php
3 if(!isset($PHP_AUTH_USER)) {
4 Header("WWW-Authenticate: Basic realm=\"My
Realm\"");
5 Header("HTTP/1.0 401 Unauthorized");
6 echo "Text to send if user hits Cancel
button\n";
7 exit;
8 } else {
9 echo "Hello $PHP_AUTH_USER.<P>";
10 echo "You entered $PHP_AUTH_PW as your
password.<P>";
11 }
12 ?>
13
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/