class MemberProcess
{
var $SQL = "";
var $ReturnArr = array("Result"=>"","Msg"=>"");
function MemberProcess() //클래스 생성자
{
$this->db = new CDB;
$this->db->Connect();
}
function CheckId($Uid) // ID존재여부를 체크한다.
{
$this->SQL = " select * from TB_manager where user_id = '$Uid' ";
$this->db->Query($this->SQL);
$this->total = $this->db->RecordCount();
return $this->total;
}
function CheckPwd($Uid,$PassWd) // 비밀번호가 맞는지 체크한다.
{
$this->SQL = " select * from TB_manager where user_id = '$Uid' and user_pwd = '$PassWd' ";
$this->db->Query($this->SQL);
// echo $this->SQL ;
$this->total = $this->db->RecordCount();
return $this->total;
}
function LoginChk($Uid, $PassWd) //유효한 사용자인지 로그인전 확인한다.
{
if($this->CheckId($Uid) <= 0)
{
$this->ReturnArr[Result] = false;
$this->ReturnArr[Msg] = $Uid."는 존재하지 않는 아이디 입니다";
}
else
{
if($this->CheckPwd($Uid, $PassWd) <= 0)
{
$this->ReturnArr[Result] = false;
$this->ReturnArr[Msg] = "비밀번호가 일치하지 않습니다.!";
}
else
{
$this->ReturnArr[Result] = true;
$this->ReturnArr[Msg] = "";
}
}
return $this->ReturnArr;
}
function LogOut($cookie_domain="") //로그아웃을 처리한다.
{
setcookie("web_id","",0,"/",$cookie_domain);
setcookie("web_name","",0,"/",$cookie_domain);
setcookie("web_email","",0,"/",$cookie_domain);
setcookie("web_level","",0,"/",$cookie_domain);
setcookie("web_company","",0,"/",$cookie_domain);
$this->ReturnArr[Result] = true;
$this->ReturnArr[Msg] = "안녕히 가십시오..";
return $this->ReturnArr;
}
function LogIn($Uid,$Pwd,$cookie_domain="") //로그인을 처리한다.
{
$RtnArr = $this->LoginChk($Uid,$Pwd);
if($RtnArr[Result])
{
$row = $this->db->fetcharray();
SetCookie("web_id",$row[user_id], 0, "/", $cookie_domain);
SetCookie("web_name",$row[user_name], 0, "/", $cookie_domain);
SetCookie("web_email",$row[user_email], 0, "/", $cookie_domain);
SetCookie("web_level",$row[user_level], 0, "/", $cookie_domain);
SetCookie("web_company",$row[member_of], 0, "/", $cookie_domain);
}
return $RtnArr;
}
}
/**********************************************************************
사용 방법
***********************************************************************
include_once "class/DB.php"; // DB연결 클래스 샘플은 아래 있당
include_once "class/MemberProcess.php"; //로그인 처리 클래스
$cMember = new MemberProcess; //클래스 생성
//로그인 처리 LogIn(아이디,비밀번호,쿠키URL)
$Cuser = $cMember->LogIn("hawk5","hawk6","mydomain.com");
//로그인 결과 처리
if($Cuser[Result])
{
echo("
<script>
location.href='/';
</script>
");
}
else
{
echo("<script>alert('$Cuser[Msg]');history.go(-1);</script>");
}
***************************************************************************/
?>
[펌] http://blog.naver.com/neohawk5?Redirect=Log&logNo=140131812745