Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

login problem

Status
Not open for further replies.

Roberti

Technical User
Joined
Mar 2, 2001
Messages
96
Location
NL
Does anybody know why this doesn't work:

<?php

$LOGIN = &quot;admin&quot;;
$PASSWORD = &quot;test&quot;;

function error ($error_message)

{
echo $error_message.&quot;<BR>&quot;;
exit;
}

IF ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == &quot;$PASSWORD&quot; )) )

{
header(&quot; Basic entrer=\&quot;Form2txt admin\&quot;&quot;);
header(&quot;HTTP/1.0 401 Unauthorized&quot;);
error(&quot;Unauthorized access...&quot;);
}

ELSE
{
print&quot;<HTML>&quot;;
print &quot;<HEAD>&quot;;
print &quot;<TITLE>Protected</TITLE>&quot;;
print &quot;</HEAD>&quot;;

print &quot;<BODY>&quot;;
print &quot;test&quot;;
print &quot;</BODY>&quot;;

print&quot;</HTML>&quot;;
}

?>

It just keeps giving the unauthorized access messages.
And is this a secure login for as far as secure goes without a database login.

Thanks in advance.

Roberti.
 
I'm sorry, that's not true. It worked for me with changes.

I changed all references to $PHP_AUTH_USER to $_SERVER['PHP_AUTH_USER'] and all references to $PHP_AUTH_PW to $_SERVER['PHP_AUTH_PW']. My php.ini register_globals setting is &quot;off&quot;, which means $PHP_AUTH_USER and $PHP_AUTH_PW don't exist.

Also, you do not specify your run environment, but $PHP_AUTH_USER and $PHP_AUTH_PW are available to PHP only if PHP is run as an Apache module.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top