Created
June 28, 2015 10:00
-
-
Save lideo/41a6de38d73e83dd5de3 to your computer and use it in GitHub Desktop.
Password protect a page with PHP
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
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != 'username' || $_SERVER['PHP_AUTH_PW'] != 'password') { | |
header('WWW-Authenticate: Basic realm="MyProject"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
die('Access Denied'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment