Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP user authorization


4:32 am on Jan 28, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 27, 2003
votes: 0

ok...i have this following script...and i always get unauthorized user even if i enter the corect username and password


$LOGIN = "User";
$PASSWORD = "password";

function error ($error_message) {
echo $error_message."<BR>";

if ( (!isset($PHP_AUTH_USER)) ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == "$PASSWORD" )) ) {
header("WWW-Authenticate: Basic entrer=\"Form2txt admin\"");
header("HTTP/1.0 401 Unauthorized");
error("Unauthorized access...");

<!-- Add code of your web page here -->
webpage code

can anyone help me fix it?

5:20 am on Jan 28, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 2, 2002
votes: 0

Hey Sfar512,
according to the PHP manual [php.net] you should use:
with more recent versions of PHP, I can't remember which one right now.
Anyway, you should try it.
5:29 am on Jan 28, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
votes: 0

Welcome to WebmasterWorld [webmasterworld.com] Sfar512.

Be sure to read Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post.

You should indeed use the superglobal $_SERVER when accessing the username and password.

Basic HTTP Authentication [faqs.org] is done according to RFC2617. There is no authentication parameter entrer defined in RFC2617. Instead the basic authentication scheme requires the realm parameter. If you use that your script should work.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members