Apache 2.0 header Auth
| From: | Josh Thomas | Date: | Mon, 14 Apr 2003 14:40:51 +0000 |
| Subject: | Apache 2.0 header Auth | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143776@lists.php.net to get a copy of this message | ||
Can you no longer use header("HTTP/1.0 401 Unauthorized"); to send and check
login information??
here is my script, right now it just stops at the login screen that the
server presents.
function authenticate ($realm="Secure Area"
,$errmsg="Please enter a username and password"
)
{
Header("WWW-Authenticate: Basic realm=\"$realm\"");
Header("HTTP/1.0 401 Unauthorized");
die($errmsg);
}
function db_authenticate($table="mysql.users",$realm="Secure Area"
,$errmsg="Please enter a username and password"
,$user_field=""
,$password_field=""
)
{
global $PHP_AUTH_USER;
global $PHP_AUTH_PW;
if (empty($PHP_AUTH_USER))
{
authenticate($realm,$errmsg.": header");
}
else
if (empty($user_field)) { $user_field = "username"; }
if (empty($password_field)) { $password_field =
"password"; }
$query = "select $user_field from $table
where $password_field =
password(lower('$PHP_AUTH_PW'))
and $user_field = lower('$PHP_AUTH_USER')
";
$result = safe_query($query);
if ($result) { list($valid_user) =
mysql_fetch_row($result); }
if (!$result || empty($valid_user))
{
authenticate($realm,$errmsg.": query");
}
}
}
Any Ideas