웹마스터 팁
page_full_width">
mysql 이용한 사용자 인증 2 (auth.inc 파일)
2005.12.15 18:04
<?
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);
}
}
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);
}
}