Forum Moderators: mack
But as I transfered all the files on my hosting provider, it tells me username and password wrong.. which I am sure cannot be wrong as it is in the script and I have access to it..
What might be the problem?
<?php
// Username and Password for authorization
$username = 'somename';
$password = 'somepassword';
if(!isset($_SERVER['PHP_AUTH_USER']) ¦¦ !isset($_SERVER['PHP_AUTH_PW']) ¦¦ ($_SERVER['PHP_AUTH_USER'] != $username) ¦¦ ($_SERVER['PHP_AUTH_PW'] != $password)) {
// The username and password are incorrect and so send the authentication headers
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate:Basic realm ="My website"');
exit('<div align="center"><h2> My website </h2> You must enter valid username and password to access this page.');
}
?>
Although to avoid this kind of problem you could always setup the pw protection from your host's cpanel as this will protect the sub-folders too while the one you posted operates with the application script(s) only.