PDA

View Full Version : HTTP Authentification problem



The Stranger
December 30th, 2006, 08:32 PM
I've created a simple HTTP authentification system that works perfectly on my computer:



//This function validates if the user input it's correct
function auth($name,$password) {
$sql = "select * from panel"; //Data from MySQL
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$mysql_name = $row['name'];
$mysql_password = $row['password'];

if($name != $mysql_name and $password != $mysql_password) {
return false;
} else {
return true;
}
}

if(!auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
header('WWW-Authenticate: Basic realm="Panel"');
header('HTTP/1.0 401 Unauthorized');
echo "error";
exit();
} //if

...the page content
However once I upload this code in the server the story it's different. I get the dialog box (name, password) displayed, but no matter what I write, I cannot pass this dialog box. I've even get rid off the mysql part and use simple variables as name and password but the result it's the same.

My configuration:
My Computer
Apache/2.0.59 (Win32)
PHP version:5.1.6
MySQL version:5.0.24a-community-nt

My Server
Apache 1.3.37 (Unix)
MySQL 4.1.21-standard
PHP 4.4.3

Thanks! any idea will be great!

MichaelxxOA
December 30th, 2006, 08:33 PM
It must have something to do with Apache, can you locate a distribution that matches that of your servers? Or at least closer. Have you seen what has changed between apache 1.3 and apache 2?

I'm not much help more than that at the moment, take care.
Michael

akram1905
January 1st, 2007, 07:29 PM
just to make your life harder : =)
i think you dont mean :


if($name != $mysql_name and $password != $mysql_password) {
instead you should have this :



if($name != $mysql_name or $password != $mysql_password) {
or instead of and ...