$PHP_AUTH
| From: | Sebastian | Date: | Sat, 15 Feb 2003 11:00:38 +0000 |
| Subject: | $PHP_AUTH | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135651@lists.php.net to get a copy of this message | ||
Greetings.
does something look wrong with this script? It prompts for password but it doesn't accept it.
I tried $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']
but it still does not accept my username and or password.
PHP v 4.2.3.
any ideas?
//------------------------- start -------------------------+
$realm = "This is a restricted zone!";
$auth = false; // Assume user is not authenticated
if (isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW)) {
mysql_connect( $checkservername, $dbcheckusername, $dbcheckpassword )
or die ( 'Unable to connect to server.' );
mysql_select_db( $dbcheckbase )
or die ( 'Unable to select database.' );
if ($encryptedpw) {
$chkpw = md5($PHP_AUTH_PW);
} else {
$chkpw = $PHP_AUTH_PW;
}
$sql = ("SELECT * FROM user
WHERE username = '$PHP_AUTH_USER'
AND password = '$chkpw' AND ( usergroupid = '6' )");
$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );
$num = mysql_numrows( $result );
if ( $num != 0 ) {
$auth = true;
}
}
if ( !$auth ) {
header( "WWW-Authenticate: Basic realm=\"$realm\"" );
header( "HTTP/1.0 401 Unauthorized" );
echo 'Authorization Required!';
exit;
}
//------------------------- end -------------------------+
Thanks for your time.
Sebastian - [BBR] Gaming Clan
http://www.BroadBandReports.com