simple code

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
sam00
Forum Newbie
Posts: 1
Joined: Thu Jan 29, 2004 12:26 pm

simple code

Post by sam00 »

I am having some problems with some very simple code.
Im just trying to get the pop-up box and input the correct user name and password then get a response saying I am authorized etc. But no matter what I try it will not continue through the program after a certain point for me to get the authorized response. So I am wondering if maybe there is something that my Apache2 has to have enabled or my php-4.3.4 ??
Anyone know why I am failing? The pop-up window comes up fine but it wont accept anything i enter. :?:

<?php

// File Name: auth02.php

// Check to see if $PHP_AUTH_USER already contains info

if (!isset($PHP_AUTH_USER)) {

// If empty, send header causing dialog box to appear

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

} else if (isset($PHP_AUTH_USER)) {

if (($PHP_AUTH_USER != "test") || ($PHP_AUTH_PW != "test123")) {

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

} else {
echo "
<P>You're authorized!</p>
";
}
}



?>
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

i'm not quirte sure how your box works, but when it's set it will always go to the second one, which means aside fomr the first pageload, or when dealing with an isp like aol that strips it, you have an issue: it will ALWAYS be there. isps like aol that strip it will always have it NOT set
Post Reply