From d5b8ebf9f1e3b69facff3e4d604f319f2c06cfb1 Mon Sep 17 00:00:00 2001 From: choibk Date: Thu, 4 Dec 2025 21:01:53 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/member.php | 40 ++++++++++++++++++++++++++++++++++------ header.php | 12 ++++++------ js/login.js | 43 +++++++++++++++++++++++++++++++++++++++++++ login.php | 29 +++++++++++++++++++++++++++++ member_input.php | 1 + pg/login_process.php | 31 +++++++++++++++++++++++++++++++ pg/member_process.php | 4 ++-- stipulation.php | 1 + 8 files changed, 147 insertions(+), 14 deletions(-) create mode 100644 js/login.js create mode 100644 login.php create mode 100644 pg/login_process.php 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 @@ - <?= $g_title ?> + <?= (isset($g_title) && $g_title != '') ? $g_title : 'SOKUREE'; ?> "; exit; } diff --git a/stipulation.php b/stipulation.php index 1e4078e..da7493a 100644 --- a/stipulation.php +++ b/stipulation.php @@ -2,6 +2,7 @@ $js_array = [ 'js/member.js']; $g_title = '약관'; +$menu_code = 'member'; include 'header.php';