diff --git a/config/member.php b/config/member.php index c334ea9..296737e 100644 --- a/config/member.php +++ b/config/member.php @@ -1,17 +1,20 @@ conn = $db; // PDO 객체 주입 } // 아이디 중복체크용 멤버 함수, 메소드 - public function id_exists($id) { + public function id_exists($id) + { $sql = "SELECT * FROM member WHERE id=:id"; $stmt = $this->conn->prepare($sql); $stmt->bindParam(':id', $id); @@ -21,11 +24,13 @@ class Member { } // 이메일 형식 체크 - public function email_format_check($email) { + public function email_format_check($email) + { return filter_var($email, FILTER_VALIDATE_EMAIL); } - public function email_exists($email) { + public function email_exists($email) + { $sql = "SELECT * FROM member WHERE email=:email"; $stmt = $this->conn->prepare($sql); $stmt->bindParam(':email', $email); @@ -35,7 +40,8 @@ class Member { } // 회원 정보 입력 - public function input($marr) { + public function input($marr) + { $sql = "INSERT INTO member(id, password, name, email, zipcode, addr1, addr2, photo, create_at, ip) VALUES (:id, :password, :name, :email, :zipcode, :addr1, :addr2, :photo, NOW(), :ip)"; $stmt = $this->conn->prepare($sql); $stmt->bindParam(':id', $marr['id']); @@ -49,6 +55,28 @@ class Member { $stmt->bindParam(':ip', $_SERVER['REMOTE_ADDR']); $stmt->execute(); + } + // 로그인 + public function login($id, $pw) + { + // 아이디로 회원 정보 조회 + $sql = "SELECT * FROM member WHERE id = :id LIMIT 1"; + $stmt = $this->conn->prepare($sql); + $stmt->bindParam(':id', $id); + $stmt->execute(); + + $member = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!$member) { + return false; // 아이디 없음 + } + + // 입력 비밀번호 vs DB 해시 비교 + if (password_verify($pw, $member['password'])) { + return true; + } else { + return false; + } } } diff --git a/header.php b/header.php index 7f21da5..a6e3070 100644 --- a/header.php +++ b/header.php @@ -4,7 +4,7 @@
-