Jump to content

http auth


ratcateme

Recommended Posts

i am trying to implement HTTP authentication this is what i have so far

$users = array("scott:".md5(a));
function authenticate($test)
{
header('WWW-Authenticate: Basic realm="Auth"');
header('HTTP/1.0 401 Unauthorized');
echo "You must enter a valid login ID and password to access this resource{$test}\n";
exit;
}
$auth = false;
if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW'])) {
authenticate(print_r($_SERVER,true));
} elseif (in_array("{$_SERVER['PHP_AUTH_USER']}:".md5($_SERVER['PHP_AUTH_PW']),$users)) {
$auth = true;
}
if (!$auth)
authenticate();

after i enter a user and password $_SERVER has no PHP_AUTH_USER or PHP_AUTH_PW what am i doing wrong

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/117683-http-auth/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.