Ok i have my auth.php and my MySQL database with 2 users in the database the passwords are encrypted with md5 and I cant get it to work properly it wont let me into my privet area on my site please help.
My auth.php is (Where USERNAMEis my username, PASSWORDis my password, DATABASE is my database name, TABLE is my table name)
<?php # login.phpl
if (!isset($_SERVER[‘php_auth_user’])) {
header(“WWW-Authenticate: Basic realm=”FSCO Login.””);
header(“HTTP/1.0 401 Unauthorized”);
echo “Sorry – You need a valid username and password to access this area of the website!n”;
exit;
} else {
mysql_connect(“localhost”, “USERNAME”, “PASSWORD”) or die(‘Error!!!!’ . mysql_error());
mysql_select_db(“DATABASE”) $md5pass = md5($_SERVER[php_auth_pw]) or die(‘Error!!!!’ . mysql_error());
$result = mysql_query(“select user_id from TABLE where username = ‘{$
if (mysql_num_row($result)) {
echo “Welcom, {$_SERVER[‘php_auth_user’]} to the user area”;
} else {
header(“WWW-Authenticate: Basic realm=”FSCO Login””);
header(“HTTP/1.0 401 Unauthorized”);
echo “Sorry – You need to enter a valid username and password to access this area of the website!n”;
exit;
}
}
?>
My table has the table headings of user_id, username, password and reg_data. (All are what they say they are but reg_data is the date and time that the user was created.)
Please can anyone help me thank you.