Skip to content

Instantly share code, notes, and snippets.

@ZAYEC77
Created December 15, 2016 21:35
Show Gist options
  • Select an option

  • Save ZAYEC77/a47852454305ed3ba642c1f1faa51392 to your computer and use it in GitHub Desktop.

Select an option

Save ZAYEC77/a47852454305ed3ba642c1f1faa51392 to your computer and use it in GitHub Desktop.
<?php
function authenticate() {
header('WWW-Authenticate: Basic realm="Test Authentication System"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
if (!isset($_SERVER['PHP_AUTH_USER'])){
authenticate();
} else {
if ($_SERVER['PHP_AUTH_USER'] == 'admin' && $_SERVER['PHP_AUTH_PW'] == 'admin') {
echo "Welcome";
} else {
authenticate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment