Try this, it works for me.
Mike
if(!isset($PHP_AUTH_USER)) {
Header("WWW-Authenticate: Basic realm=\"User Database\"");
Header("HTTP/1.0 401 Unauthorized");
echo "<H1>ERROR</H1>You must enter a correct username and password
in order to proceed\n";
exit;
}
else {
if ($PHP_AUTH_USER=="admin" && $PHP_AUTH_PW=="love2change"){
print "You are successfully authenticated";
}
else {
Header("WWW-Authenticate: Basic realm=\"User Database\"");
Header("HTTP/1.0 401 Unauthorized");
echo "You did not supply proper credentials and are therefore denied
login\n";
exit;
}
}
?>
-----Original Message-----
From: Amer Alhabsi [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 27, 2001 1:42 AM
To: [EMAIL PROTECTED]
Subject: [PHP] User Authentication
Hi,
I'm trying to use an authentication method I found in a tutorial in the
net. The server prompts for username/password. But if I enter the hard coded
values (or any other values) the server rejects them with a message
authorization failed.
I use PHP 4 as a module on IIS
Thanks very much for any help,
here is the program I got from the tutorial.
<?php
if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW))
|| ( $PHP_AUTH_USER != 'user' ) || ( $PHP_AUTH_PW != 'open' ) )
header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else
echo 'Success!';
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]