Advertisement
danhezee

password stuff

Sep 19th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.     if (!isset($_SERVER['PHP_AUTH_USER'])) {
  3.         header("WWW-Authenticate: Basic realm=\"Private Area\"");
  4.         header("HTTP/1.0 401 Unauthorized");
  5.         print "Sorry - you need valid credentials to be granted access!\n";
  6.         exit;
  7.     } else {
  8.         if (($_SERVER['PHP_AUTH_USER'] == 'username') && ($_SERVER['PHP_AUTH_PW'] == 'password')) {
  9. ?>
  10.             <!--Content here--->
  11.             <!--In my case it was an iframe to another site>
  12. <?php
  13.         } else {
  14.             header("WWW-Authenticate: Basic realm=\"Private Area\"");
  15.             header("HTTP/1.0 401 Unauthorized");
  16.             print "Sorry - you need valid credentials to be granted access!\n";
  17.             exit;
  18.         }
  19.     }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement