웹마스터 팁

<?

cfunction authenticate() {
   Header( "WWW-authenticate: basic realm="BBS ADMIN 영역"");
   Header( "HTTP/1.0 401 Unauthorized");
   $title = "Invalid Login";
?>
아이디와 암호가 필요합니다 !
<?
exit;

}
if (!isset($PHP_AUTH_USER)) {
   authenticate();
} else {
   mysql_pconnect('','mysql','') or die("Unable to connect to SQL server");
   mysql_select_db("test") or die("Unable to select database");
   $result = mysql_query("select name, level from member where id = '$PHP_AUTH_USER' and passwd='$PHP_AUTH_PW'");
   if(!mysql_num_rows($result))
     {
     authenticate();
     }
   else
   {
     $userinfo = mysql_fetch_array($result);
   }
}