Hi I'm executing:
<?php
// File Name: htmladmin.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
Header("WWW-Authenticate: Basic realm=\"Blue Accord\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
} else if (isset($PHP_AUTH_USER)) {
// If non-empty, check the database for matches
// connect to MySQL
$hostname="localhost";
$username="xxxx";
$password="xxxx";
$dbname="users";
$usertable="id";
mysql_connect($hostname, $username, $password)
or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db($dbname)
or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT *
FROM $usertable
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
if ($num != "0") {
echo "<P>You're authorized!</p>";
exit;
} else {
header("WWW-Authenticate: Basic realm=\"Blue Accord\"");
header("HTTP/1.0 401 Unauthorized");
echo "Authorization Required.";
exit;
}
}
?>
This code was on this board as an example of how to use sessions in php4, but when i use the code i get the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@blueaccord.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Does anyone know what is going on?? I know that php4 is working correctly becasue I have alot of other scripts working without a problem.
Please help!