Problem with authentication?
Hey all:
I seem to be having a bit of a problem here.
This code worked on one machine, but not on our newest one.
Should any of the following code change with the lastest upgrade of PHP?
class err_auth {
function printError() {
header('WWW-Authenticate: Basic realm=Missy Admin 2');
header('HTTP/1.0 401 Unauthorized'); // Display message if user cancels dialog
print("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">
<HTML><HEAD>
<TITLE>401 Authorization Required</TITLE>
</HEAD><BODY>
<H1>Authorization Required</H1>
This server could not verify that you are authorized to access the document requested.
Either you supplied the wrong credentials (e.g., bad password), or your browser
doesn't understand how to supply the credentials required.<P>
<HR>
<ADDRESS>Apache/1.3.22 Server at <A HREF=\"mailto:gonzo@missy.shef.ac.uk\">m
Port 80</ADDRESS>
</BODY></HTML>");
exit;
}
}
$link = new err_auth();
$query = "SELECT * FROM webbietable";
$result = mysql_query($query) or die("Query Failed!");
print($mysql_error);
if (!isset($PHP_AUTH_USER) && !isset($PHP_AUTH_PW)) {
// If empty, send header causing dialog box to appear
$link-> printError();
}
$i=mysql_num_rows($result);
while($a_row = mysql_fetch_array($result)){
print(gettype($a_row));
print($a_row);
//while ($i>0){
//foreach($line as $col_value){
//extract($a_row);
// print("arowusername=".$username);
if ($a_row[username]==$PHP_AUTH_USER){
// print($PHP_AUTH_USER.",". $a_row[username].",".$PHP_AUTH_PW.",".$a
$error="noerror";
// print("<br><b>noERROR!!!</b>");
// $link->printError();
}
if ($a_row[password]==$PHP_AUTH_PW){
// print($PHP_AUTH_USER.",". $a_row[username].",".$PHP_AUTH_PW.",".$a
$error2="noerror2";
// print("<br><b>noERROR!!!</b>");
// $link->printError();
}
//}
//print($PHP_AUTH_USER.",". $a_row[username].",".$PHP_AUTH_PW.",".$a
//$i--;
}
if ($error!="noerror" | $error2!="noerror2"){
//print("<br><b>ERROR!!!</b>");
$link-> printError();
}?>
