Password Box
Posted: Thu Jul 08, 2004 3:01 pm
Does anyone know how to create those nifty password boxes that are created when you use .htaccess?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
function check_user($username, $password) {
if( ($username == "me") && ($password == "secret") ) return true;
return false;
}
$logged_in = false;
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
$logged_in = check_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
if(!$logged_in) {
header("HTTP/1.1 401 Unauthorized");
header("WWW-Authenticate: Basic realm="Something"");
exit;
} else {
// display your protected content here
}