Hello,
I am trying to protect a page with php&mysql.
I do this on *nix servers with no problem by requiring an include file which contains:
mysql_connect("localhost","root","xxxxxx")
or die ("Unable to connect to database!");
mysql_select_db("MyDB")
or die ("Unable to select the DB!");
$query = "
select * from users
where username='$PHP_AUTH_USER' and password = '$PHP_AUTH_PW'
";
$result = mysql_query($query);
$numrows =mysql_num_rows($result);
mysql_close();
if($numrows != 1) {
//auth failed!!!!
header('WWW-Authenticate: Basic realm="This is my protected page!"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required!';
echo 'Hit Reload to Try Again. Session Logged';
exit();
}
$username=mysql_Result($result,0,"username");
$password=mysql_Result($result,0,"password");
This code does not work on Windows. Any tips or hints how to do this on Windows Server?
Thanks