Hi,
I use Win 2k with IIS and PHP4
This is the code I use for the authentication. But I don't know why I get an the following error message:
Warning: Undefined variable: PHP_AUTH_USER in test1.php on line 7
Under linux this code just works fine. Any help would be appreciated.
Code
<?
function authenticate()
{
Header( "WWW-authenticate: basic realm='MySQL/PHP Demo'");
Header( "HTTP/1.0 401 Unauthorized");
echo "You must enter a valid login ID and password to access this resource\n";
echo $PHP_AUTH_USER;
exit;
}
if(!isset($PHP_AUTH_USER))
{
authenticate();
}
else
{
mysql_connect('localhost','username','password');
mysql_select_db("Database");
$result = mysql_query("select * FROM users where name = '$PHP_AUTH_USER'");
$row = mysql_fetch_array($result);
if ($PHP_AUTH_PW!=$row["password"] || $PHP_AUTH_USER!=$row["name"]) authenticate();
}
echo "User ID :".$row["id"];
?>
The Database has 3 cols
id -> primary key,
name -> TEXT,
password -> TEXT