header validate

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

header validate

Post by shiznatix »

Ok so I am doing some testing and I am using the header to force authentication. Here is the code stolen from the zend website

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>";

} 
 
?>
now if i hit cancel it says 'Authorization Required' but if I hit 'OK' then it just asks for my username and password again even though i entered stuff in the fields! why? how? who? help?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you have register_globals on? The code you have was written for them to be on.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

and there it is laying in the $_SERVER superglobal. *sigh* ill get it someday
Post Reply