Newbie Problem: problem with HTTP authentication
Posted: Mon Aug 08, 2005 10:07 am
I took the following code from PHP manual, but it doesn't work. Anyone has idea? I am running in Fedora Core 3, and my PHP is 4.3.11, Apache is 2.0.53-3.2.
feyd | you're new, so I'll go light for now.. please use
Code: Select all
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>feyd | you're new, so I'll go light for now.. please use
Code: Select all
tags when posting php code.[/color]