Page 1 of 1

Password Box

Posted: Thu Jul 08, 2004 3:01 pm
by AlbinoJellyfish
Does anyone know how to create those nifty password boxes that are created when you use .htaccess?

Posted: Thu Jul 08, 2004 4:05 pm
by xisle

Posted: Thu Jul 08, 2004 5:02 pm
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.

Posted: Thu Jul 08, 2004 5:14 pm
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
  }