Hi again. I now get the above error with the exact same code as in my previous question. All I did was to rearrange the lines...no code changes...help!
To assist you experts, line 11 contains this code - header(‘WWW-Authenticate: Basic realm=”secret section”’);
Then when I remove the colon, I get a new error - syntax error, unexpected T_STRING in /home/allummfa/public_html/auth.php on line 11.
This code is supposed to tell the web server to send the headers to the client's browser to prompt for a username and password when the user tries to access my restricted web page. Here's my complete coding 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”);
?>