basic_auth.php 411 B

123456789101112
  1. <?php
  2. $username = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : false;
  3. $password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : false;
  4. if ($username == 'mink-user' && $password == 'mink-password') {
  5. echo 'is authenticated';
  6. } else {
  7. header('WWW-Authenticate: Basic realm="Mink Testing Area"');
  8. header('HTTP/1.0 401 Unauthorized');
  9. echo 'is not authenticated';
  10. }