function user_auth(){ $auth['username']='ankhbaatar'; $auth['password']='PASSWORD_HERE'; if(!isset($_SERVER['PHP_AUTH_USER'])) { header("WWW-Authenticate: Basic realm=\"Private Area\""); header("HTTP/1.0 401 Unauthorized"); exit; } else { if (($_SERVER['PHP_AUTH_USER'] == $auth['username']) && ($_SERVER['PHP_AUTH_PW'] == $auth['password'])) { } else { header("WWW-Authenticate: Basic realm=\"Private Area\""); header("HTTP/1.0 401 Unauthorized"); //print "Sorry - you need valid credentials to be granted access!\n"; exit; } } unset($_SERVER['PHP_AUTH_USER']); }