HTTP Authentication w/IIS
| From: | Shane McBride | Date: | Sun, 04 Feb 2001 04:44:45 +0000 |
| Subject: | HTTP Authentication w/IIS | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38029@lists.php.net to get a copy of this message | ||
OK, I loaded PHP with the ISAPI filter, but still no luck with authentication..
Here's the basic script that works on Apache/Linux:
<?
// File name: admin_menu.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="The Back Care Center Admin Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required!';
exit;
} else if (isset($PHP_AUTH_USER)) {
if (($PHP_AUTH_USER !="test") || ($PHP_AUTH_PW !="123")) {
header('WWW-Authenticate: Basic realm="The Back Care Center Admin Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required!';
exit;
} else {
// Start echo statement
echo "hello";
}
}
?>