I am trying to use the PHP authentication to verify a user
here is the code:
<?php
if(!isset ($PHP_AUTH_USER)) :
header('WWW-Authenticate: Basic realm="user verification PHP"');
header('HTTP/1.0 401 Unauthorized');
print "you need access :P";
exit;
else:
$dbcnx = mysql_connect("192.168.1.27", "root", "");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " . "database server please try again later.</p>" );
exit();
}
mysql_select_db("database1", $dbcnx);
if (! @mysql_select_db("database1") ) {
echo( "<p>Unable to locate the database1 " . "database at this time.</p>" );
exit();
}
$result = @mysql_query("SELECT first_name, last_name
FROM users
WHERE first_name='$PHP_AUTH_USER' and last_name='$PHP_AUTH_PW'");
if (mysql_numrows($result) != 1):
echo " Not verifed" ;
header('WWW-Authenticate: Basic realm="user verification PHP"');
header('HTTP/1.0 401 Unauthorized');
exit;
else:
$userid = mysql_result (user_authenticate, 0, $result);
endif;
endif;
?>


