Ok, so I got some sample code and changed a bunch of stuff around so that this thing checks my database for my name & pass...no matter what data I enter for the user name and password I get prompted 3 times for them and get a blank page in return...somebody help!
<?php
if (!isset($PHP_AUTH_USER)) {
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
else if (isset($PHP_AUTH_USER)) {
// If non-empty, check the database for matches
// connect to MySQL
mysql_connect("Default", "root", "") or die ("Unable to connect to database.");
mysql_select_db("newsdb") or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT * FROM users WHERE name='$PHP_AUTH_USER' and pass='$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="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
} ?>