HTTP Authentication and PHP
Posted: Thu Aug 08, 2002 10:00 am
I am trying to have the browser require authentication before loadiing a page.
here is the code that calls that authentication
This is the funtction that is called
Can anyone help me?
here is the code that calls that authentication
Code: Select all
require_once("spall_fns.php");
if (! isset($area))
authorize();Code: Select all
require_once("/usr/home/faog/functions/db_fns.php");
function authorize($_SERVER)
{
if (!isset($_SERVERї'PHP_AUTH_USER']))
{
header("WWW-Authenticate: Basic realm='Lufkin.org'");
header('HTTP/1.0 401 Unauthorized');
echo 'You are not a register user. If you need to be please contact the webmaster';
exit;
}
else
{
$query = "SELECT * FROM users WHERE username = '".$_SERVERї'PHP_AUTH_USER']."' AND password = PASSWORD('".$_SERVERї'PHP_AUTH_PW']."')";
$result = query_db($query);
$numrow = mysql_num_rows($result);
echo $numrow."<BR>";
if($numrow == 1)
{
$user = mysql_fetch_array($result);
load_mainpage($userї"uid"]);
}
else
echo 'You cannot be logged due to incorrect username or password. Please contact the webmaster with any questions';
}
}