php http basic auth
define('HTTP_USER','user'); define('HTTP_PASS','pass'); if(isset($_SERVER['PHP_AUTH_USER'])&&($_SERVER['PHP_AUTH_PW']==HTTP_PASS)&&(strtolower($_SERVER['PHP_AUTH_USER'])==HTTP_USER)){ //success } else{ header('WWW-Authenticate: Basic realm="Authorization required"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authenticate required!'; exit(); }