Hello all,
I need help in setting up a Database-Driven Authentication using
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
} else {
$connection = mysql_connect("localhost", "BOZO", "OHPLEASE")
or die ("Couldn't connect to server.");
$db = mysql_select_db("COOLNESS", $connection)
or die ("Couldn't select database.");
$sql = "SELECT id
FROM data
WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'";
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_numrows($result);
if ($num == 1) {
echo "<P>You are valid!<br>";
echo "Your username is $PHP_AUTH_USER<br>";
echo "Your password is $PHP_AUTH_PW</p>";
} else if ($num == 0) {
echo "You are not authorized!";
}
}
?>
This did work before I installed the new php with Global variables Off
User Authentication With Global variables Off
Moderator: General Moderators
-
freebsd_dude
- Forum Newbie
- Posts: 1
- Joined: Sat Nov 16, 2002 10:09 pm
take a look at http://www.php.net/manual/en/reserved.variables.php