-
-
Save drewgates/212ba79f156d3e92e8f433312c5fb892 to your computer and use it in GitHub Desktop.
PHP Simple Page Authentication / Password Protect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
header("Content-type: text/html; charset=utf-8"); | |
if(empty($_SERVER['PHP_AUTH_USER'])) { | |
header('WWW-Authenticate: Basic realm=""'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo 'Password Required'; | |
exit; | |
} else { | |
$password = "password"; | |
if( | |
($_SERVER['PHP_AUTH_PW'] != $password)) { | |
header('WWW-Authenticate: Basic realm=""'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo 'Login and Password Required'; | |
exit; | |
} else { | |
echo "<title>".(isset($title)?$title:"TITLE")."</title>\n"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment