(newbie)
I have taken some code directly out of a book:
<?php
// if we are using IIS, we need to set $PHP_AUTH_USER and $PHP_AUTH_PW
if (substr($SERVER _SOFTWARE, 0, 9) == 'Microsoft' &&
!isset($PHP_AUT H_USER) &&
!isset($PHP_AUT H_PW) &&
substr($HTTP_AU THORIZATION, 0, 6) == 'Basic '
)
{
list($PHP_AUTH_ USER, $PHP_AUTH_PW) =
explode(':', base64_decode(s ubstr($HTTP_AUT HORIZATION, 6)));
}
// Replace this if statement with a database query or similar
if ($PHP_AUTH_USER != 'user' || $PHP_AUTH_PW != 'pass')
{
// visitor has not yet given details, or their
// name and password combination are not correct
header('WWW-Authenticate: Basic realm="WhosOnCa m Moderators"');
if (substr($SERVER _SOFTWARE, 0, 9) == 'Microsoft')
header('Status: 401 Unauthorized');
else
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Go Away!</h1>';
echo 'You are not authorized to view this resource.';
echo "User: $PHP_AUTH_USER Password: $PHP_AUTH_PW <BR />";
echo "Header: $HTTP_AUTHORIZA TION";
}
etc.
I am getting the login window, and am entering the user/pass combination.
The code is sending me to the '401' clause and telling me all three
variables are blank.
Any help appreciated.
BT3
I have taken some code directly out of a book:
<?php
// if we are using IIS, we need to set $PHP_AUTH_USER and $PHP_AUTH_PW
if (substr($SERVER _SOFTWARE, 0, 9) == 'Microsoft' &&
!isset($PHP_AUT H_USER) &&
!isset($PHP_AUT H_PW) &&
substr($HTTP_AU THORIZATION, 0, 6) == 'Basic '
)
{
list($PHP_AUTH_ USER, $PHP_AUTH_PW) =
explode(':', base64_decode(s ubstr($HTTP_AUT HORIZATION, 6)));
}
// Replace this if statement with a database query or similar
if ($PHP_AUTH_USER != 'user' || $PHP_AUTH_PW != 'pass')
{
// visitor has not yet given details, or their
// name and password combination are not correct
header('WWW-Authenticate: Basic realm="WhosOnCa m Moderators"');
if (substr($SERVER _SOFTWARE, 0, 9) == 'Microsoft')
header('Status: 401 Unauthorized');
else
header('HTTP/1.0 401 Unauthorized');
echo '<h1>Go Away!</h1>';
echo 'You are not authorized to view this resource.';
echo "User: $PHP_AUTH_USER Password: $PHP_AUTH_PW <BR />";
echo "Header: $HTTP_AUTHORIZA TION";
}
etc.
I am getting the login window, and am entering the user/pass combination.
The code is sending me to the '401' clause and telling me all three
variables are blank.
Any help appreciated.
BT3
Comment