note 96178 deleted from features.http-auth by danbrown
| From: | danbrown@php.net | Date: | Fri, 12 Feb 2010 16:32:38 +0000 |
| Subject: | note 96178 deleted from features.http-auth by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165911@lists.php.net to get a copy of this message | ||
Note Submitter: jakefree at verizon dot net
Reason: useless
----
Example 1 is utterly useless. All it would do is force the browser's atuhentication box to show
but all anyone would have to do is just enter any string for a username and they will be let in.
try this:
<?php
define("PHP_AUTH_USER", "username");
define("PHP_AUTH_PW", "password");
//if (!isset($_SERVER['PHP_AUTH_USER']))
if ($_SERVER['PHP_AUTH_USER'] != PHP_AUTH_USER || $_SERVER['PHP_AUTH_PW'] !=
PHP_AUTH_PW )
{
header('WWW-Authenticate: Basic realm="Customer Management"');
header('HTTP/1.0 401 Unauthorized');
echo 'You need to login with proper username and password to gain access to this
page';
exit;
}
else
{
$welcomeMessage = "<h3>Hello , welcome to the Customer Management
Suite</h3>";
}
?>