Password Box

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

Password Box

Post by AlbinoJellyfish »

Does anyone know how to create those nifty password boxes that are created when you use .htaccess?
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

AlbinoJellyfish
Forum Commoner
Posts: 76
Joined: Sun Apr 04, 2004 7:39 pm

Post by AlbinoJellyfish »

i get how to use htpassword, im just wondering, if anyone has used phpmyadmin on the http setting, how to get that box to enter in info.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

function check_user($username, $password) {
     if( ($username == "me") && ($password == "secret") ) return true;
     return false;
  }
  $logged_in = false;
  if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
     $logged_in = check_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
  if(!$logged_in) {
     header("HTTP/1.1 401 Unauthorized");
     header("WWW-Authenticate: Basic realm="Something"");
     exit;
  } else {
   // display your protected content here
  }
Post Reply