Page 1 of 1

Quick question about PHP_AUTH_USER

Posted: Thu Sep 18, 2003 3:31 pm
by Linkjames
I have a PHP file that contains the following

Code: Select all

<?php 
     
if ((!isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW))) { 

    header( 'WWW-Authenticate: Basic realm="Private"' ); 
    header( 'HTTP/1.0 401 Unauthorized' ); 
    echo 'Authorization Required.'; 
    exit; 

} else { 

    echo "You entered $PHP_AUTH_USER for a username.<BR>"; 
    echo "You entered $PHP_AUTH_PW for a password.<BR>"; 

} 

?>
When loaded, it pops up the dialog box asking for username and password. As you can see, there isn't one. The script should let you in as long as you enter somthing. But this keeps popping up the box every time you click ok.
Any ideas? I have checked it with 2 browsers, and run it from 2 servers, and still the same problem.

Help

cheers - James

Posted: Thu Sep 18, 2003 6:31 pm
by volka
as of php 4.1 these values are elements of the superglobal array $_SERVER and as of php 4.2 they are not registered in the global scope by default.

see also:
Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+
php manual: Predefined Variables