malformed header: Apache for win and php
Posted: Sat Feb 08, 2003 2:25 am
Hi, everybody.
I have a problem with PHP authentication code.
I am using Apache as a server on Win2000Profesional.
When I am executing "authenticate" function which is described in a
book, error message is desplayed in the browser : Something about an
internal server error.
So can you help about this? Thanks
Here is the code:
And the error, which was displayed in browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your
request.
Also I checked in Apache error.log file, and there was the following error:
Tue May 01 22:42:49 2001] [error] [client 127.0.0.1] malformed header from script. Bad
header=HTTP/1.0 401 Unauthorized: c:/php/php.exe
That's it.
I have a problem with PHP authentication code.
I am using Apache as a server on Win2000Profesional.
When I am executing "authenticate" function which is described in a
book, error message is desplayed in the browser : Something about an
internal server error.
So can you help about this? Thanks
Here is the code:
Code: Select all
<?php
if (!isset($PHP_AUTH_USER))
{
HEADER ("WWW-authenticate: basic realm="Restricted area"");
HEADER ("HTTP/1.0 401 Unauthorized");
echo "You failed to provide the correct password...\n";
exit;
}
else
{
mysql_select_db("warranty");
$user_id=strtolower($PHP_AUTH_USER);
$result=mysql_query("SELECT password FROM admin " . "WHERE user =
'$username'");
$row = mysql_fetch_array ($result);
if ($PHP_AUTH_PW != $rowї"password"])
{
HEADER ("WWW-authenticate: basic realm="Restricted area"");
HEADER ("HTTP/1.0 401 Unauthorized");
echo "You failed to provide the correct password...\n";
exit;
}
}
?>And the error, which was displayed in browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your
request.
Also I checked in Apache error.log file, and there was the following error:
Tue May 01 22:42:49 2001] [error] [client 127.0.0.1] malformed header from script. Bad
header=HTTP/1.0 401 Unauthorized: c:/php/php.exe
That's it.