Skip to content

Instantly share code, notes, and snippets.

@lideo
Created June 28, 2015 10:00
Show Gist options
  • Save lideo/41a6de38d73e83dd5de3 to your computer and use it in GitHub Desktop.
Save lideo/41a6de38d73e83dd5de3 to your computer and use it in GitHub Desktop.
Password protect a page with PHP
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