Sorry I am new and dont know how to do a new post so I will try it under a similar topic:
I am trying to do an Admin-login for the administrator to check users in database, just a tutorial in a book.
The problem is it is ACCESS DENIED before I even get the login box.
<?php //Script 12.13 - authentication.php
$authorized = FALSE; // Initialize a variable.
//Check for authentication submission.
if( (isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW']))){
if( ($_SERVER['PHP_AUTH_USER'] == 'maggie') AND ($_SERVER['PHP_AUTH_PW'] == 'teddybears')){
$authorized = TRUE;
}
}
if (!$authorized){
header('WWW-Authenticate: Basic realm="Administration"');
header('HTTP/1.0 401 Unauthorized');
}
?>
<?php //# Script 8.2 indexAdmin.php
require_once ('inc/config.inc');//Connect to db.
require_once ('inc/authentication.php');
$page_title = 'Salty Paws Admin Home Page';
include_once ('inc/admin_header.html');
if (!$authorized){
echo 'Please enter a valid username and password. Click <a href="indexAdmin.php">here</a> to try again.';
} else {
echo 'You have been authenticated.';
}
include_once ('./inc/admin_footer.html');
?>
Does anyone have an idea why this is? Any advise would be greatly appreciated.