if(!isset($PHP_AUTH_USER)) {
Header("WWW-authenticate: basic realm=\"XXX\"");
Header("HTTP/1.0 401 Unauthorized");
$title="Login Instructions";
?>
In order to enter this section of the web site, you must be an XXX
subscriber. If you are a subscriber and you are having trouble logging
in,
please contact support@xxx.com.
exit;
} else {
mysql_pconnect("localhost","nobody","") or die("Unable to connect to
SQL server");
mysql_select_db("xxx") or die("Unable to select database");
$user_id=strtolower($PHP_AUTH_USER);
$password=$PHP_AUTH_PW;
$query = mysql_query("select * from users where user_id='$user_id' and
password='$password'");
if(!mysql_num_rows($query)) {
Header("WWW-authenticate: basic realm=\"XXX\"");
Header("HTTP/1.0 401 Unauthorized");
$title="Login Instructions";
?>
In order to enter this section of the web site, you must be an XXX
subscriber. If you are a subscriber and you are having trouble
logging in,
please contact support@xxx.com.
exit;
}
/* Here I pick out some other useful info from my database that
then available to any script that includes this file */
$name=mysql_result($query,0,"name");
$email=mysql_result($query,0,"email");
mysql_free_result($query);
}
?>