
April 1st, 2003, 01:39 PM
|
|
Junior Member
|
|
Join Date: Apr 2003
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Help with PHP Authentication and Realm?
I read the Mysql, PHP article here on DevArticles about setting this up but I have a problem. How exactly does the Realm work not sure if I understand, but anyways when using this basic code here with a user and password hard coded, the authentication box just keeps popping back up after I have entered the correct user and password. Any help
PHP Code:
<?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 != "admin") || ($PHP_AUTH_PW != "abc123")) {
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>
";
}
}
?>
Last edited by fearx24 : April 1st, 2003 at 01:52 PM.
|