Problem in PHP?
Posted: Mon May 05, 2008 4:21 am
I am trying to get this php script to work for the admin section - I am following the instructions on how to add a username/password in mysql. It still doesn't work. Is there a glitch in the coding? Here it is:
<?
if (!isset ($PHP_AUTH_USER)) {
Header ("WWW-Authenticate: Basic realm=\"Administration\"");
Header ("HTTP/1.0 401 Unauthorized");
echo ("Login incorrect. Names and passwords are case sensitive.");
exit;
} else {
$user = $PHP_AUTH_USER;
$password = $PHP_AUTH_PW;
$query = "select * from admin where username = '$user' and password = '$password'";
$result = mysql_db_query("jobs", $query);
if (mysql_num_rows ( if (mysql_num_rows ($result) != 1) {
Header ("WWW-Authenticate: Basic realm=\"Administration\"");
Header ("HTTP/1.0 401 Unauthorized");
echo ("Login incorrect. Namesand passwords are case sensitive.");
exit;
}
}
<?
if (!isset ($PHP_AUTH_USER)) {
Header ("WWW-Authenticate: Basic realm=\"Administration\"");
Header ("HTTP/1.0 401 Unauthorized");
echo ("Login incorrect. Names and passwords are case sensitive.");
exit;
} else {
$user = $PHP_AUTH_USER;
$password = $PHP_AUTH_PW;
$query = "select * from admin where username = '$user' and password = '$password'";
$result = mysql_db_query("jobs", $query);
if (mysql_num_rows ( if (mysql_num_rows ($result) != 1) {
Header ("WWW-Authenticate: Basic realm=\"Administration\"");
Header ("HTTP/1.0 401 Unauthorized");
echo ("Login incorrect. Namesand passwords are case sensitive.");
exit;
}
}