Hi
I am trying to teach myself PHP by following the examples in this book:
I’ve uploaded the example12-2.php file to my domain but it doesn’t work. Code as follows:
[php]<?php
$username = ‘admin’;
$password = ‘letmein’;
if (isset($_SERVER[‘PHP_AUTH_USER’]) &&
isset($_SERVER[‘PHP_AUTH_PW’]))
{
if ($_SERVER[‘PHP_AUTH_USER’] == $username &&
$_SERVER[‘PHP_AUTH_PW’] == $password)
echo “You are now logged in”;
else die(“Invalid username / password combination”);
}
else
{
header(‘WWW-Authenticate: Basic realm=“Restricted Section”’);
header(‘HTTP/1.0 401 Unauthorized’);
die (“Please enter your username and password”);
}
?>
[/php]
The problem does not seem to be with the code as it is working here:
http://lpmj.net/12/example12-2.php
Thanks in advance to anyone who can help.