Page 1 of 1

simple code

Posted: Thu Jan 29, 2004 12:26 pm
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>
";
}
}



?>

Posted: Thu Jan 29, 2004 12:31 pm
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