Hi I'm trying to apply user authentication with HTTP on my site but i get the above error. Can anyone say whats wrong?? I cant figure it out. Here's my code below:
<?php
/* Program: Auth.php
* Desc: Program that prompts for a user name and
* password from the user using HTTP authentication.
* The program then tests whether the user
* name and password match a user name and password
* pair stored in a MySQL database.
*/
//Testing whether the user has been prompted for a user nameif(!isset($_SERVER[‘PHP_AUTH_USER’])){header(‘WWW-Authenticate: Basic realm=”secret section”’);header(‘HTTP/1.0 401 Unauthorized’);exit(“This page requires authentication!”);}
// Testing the user name and password entered by the user
else{
include(“Vars.inc”);
$user_name = trim($_SERVER[‘PHP_AUTH_USER’]);
$user_password = trim($_SERVER[‘PHP_AUTH_PW’]);
$connection = mysql_connect($host,$user,$password)or die (“Couldn’t connect to server.”);$db = mysql_select_db($database,$connection)or die (“Couldn’t select database.”);$sql = “SELECT user_name FROM Valid_User WHERE user_name = ‘$user_name’AND password = md5(‘$user_password’)”;$result = mysql_query($sql)or die(“Couldn’t execute query.”);$num = mysql_num_rows($result);if ($num < 1) // user name/password not found
{
exit(“The User Name or Password you entered is not valid.<br>”);
}
}
//web page content.
include(“imagegallery.inc”);
?>