<?
/* Check for values in $PHP_AUTH_USER and $PHP_AUTH_PW */
if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) {
/* No values: send headers causing dialog box to appear */
header('WWW-Authen
ticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
} else
if ((isset($PHP_AUTH_USER)) &&
(isset($PHP_AUTH_PW))){
/* Values contain some values, so check to see if they're correct */
if (($PHP_AUTH_USER != "validname") || ($PHP_AUTH_PW != "goodpassword")) {
/* If either the username entered is incorrect, or the password entered is incorrect, send the headers causing dialog box to appear */
header('WWW-Authen
ticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
} else
if (($PHP_AUTH_USER == "validname") || ($PHP_AUTH_PW == "goodpassword")) {
/* if both values are correct, print success message */
echo "<P>You're authorized!</p>";
}
}
?>