Just created a script that requires people to login to access a certain page. Here is the code:
$username = 'test';
$password = 'test';
($_SERVER['PHP_AUTH_USER'] != $username) ||
($_SERVER['PHP_AUTH_PW'] != $password)
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="emailDB Authentication"');
This code is being included into another file with:
<?php require_once('dynamic/security.php') ?>
It is located at the very top of the file with no spaces.
When I attempt to login with the username and password ("test") at the prompt this script produces, the prompt appears again and denies me access to the page it protects.
What am I doing wrong?
P.S. it works on my localhost when viewing it in Firefox, but does not work on live websites.