PDA

View Full Version : Authentication page repeats 3 times and dies


ConfusedOfLife
11-12-2002, 11:08 PM
I have this code to ask for the user name and password, but it pops up 3 times asking them and
then shows me the message that I put those who press the cancel button!


<?php
if(!isset($PHP_AUTH_USER)) {
header("WWW-Authenticate: Basic realm=\"My Realm\"");
header("HTTP/1.0 401 Unauthorized");
echo "Text to send if user hits Cancel button\n";
exit;
} else {
echo "<p>Hello $PHP_AUTH_USER.</p>";
echo "<p>You entered $PHP_AUTH_PW as your password.</p>";
}
?>

Nightfire
11-13-2002, 09:02 AM
:confused: You're not even connecting to the DB, so it's bound to not let you in, you're always gonna have the wrong username and password. Unless you're not showing all your script.

ConfusedOfLife
11-13-2002, 09:04 PM
Oopse! I didn't know that! I'm a beginner in PHP and I just got the code from PHP manual, they didn't say that I have to connect anything to DB! Maybe it's so clear that everybody knows! Thanx anyway.