homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP user authorization
php
Sfar512

10+ Year Member



 
Msg#: 888 posted 4:32 am on Jan 28, 2003 (gmt 0)

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

<?php

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

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

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?

 

transistor

10+ Year Member



 
Msg#: 888 posted 5:20 am on Jan 28, 2003 (gmt 0)

Hey Sfar512,
according to the PHP manual [php.net] you should use:
$_SERVER["PHP_AUTH_USER"] with more recent versions of PHP, I can't remember which one right now.
Anyway, you should try it.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 888 posted 5:29 am on Jan 28, 2003 (gmt 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.

Andreas

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved