From 921b3f042bf6e6c861de10c32a38e0c47f45c6f4 Mon Sep 17 00:00:00 2001 From: choibk Date: Thu, 4 Dec 2025 10:30:36 +0900 Subject: [PATCH] =?UTF-8?q?ID/Password=20=EC=A4=91=EB=B3=B5=20=EB=B0=8F=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EC=97=AC=EB=B6=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- header.php | 9 +++-- js/member.js | 4 +-- js/member_input.js | 80 +++++++++++++++++++++++++++++++++++++++++++ member_input.php | 29 ++++++++++------ pg/member_process.php | 18 ++++++++++ stipulation.php | 8 ++++- 6 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 js/member_input.js create mode 100644 pg/member_process.php diff --git a/header.php b/header.php index 1992f52..0606322 100644 --- a/header.php +++ b/header.php @@ -10,8 +10,13 @@ - - + ' .PHP_EOL; + } + } + ?> diff --git a/js/member.js b/js/member.js index 7944e0f..a2f0edf 100644 --- a/js/member.js +++ b/js/member.js @@ -19,7 +19,7 @@ document.addEventListener("DOMContentLoaded", () => { const f = document.stipulation_form f.chk.value = 1 f.submit() - - }) + + }) }) \ No newline at end of file diff --git a/js/member_input.js b/js/member_input.js new file mode 100644 index 0000000..6a776a3 --- /dev/null +++ b/js/member_input.js @@ -0,0 +1,80 @@ +document.addEventListener("DOMContentLoaded", () => { + + // 아이디 중복 체크 + const btn_id_check = document.querySelector("#btn_id_check") + btn_id_check.addEventListener("click", () => { + const f_id = document.querySelector("#f_id") + + if (f_id.value.trim() === '') { + alert('아이디를 입력해 주세요'); + f_id.focus(); + return; + } + + + // AJAX + const f1 = new FormData() + f1.append('id', f_id.value) + f1.append('mode', 'id_chk') + + const xhr = new XMLHttpRequest() + xhr.open("POST", "/member/pg/member_process.php", true); //절대경로 + + xhr.send(f1) + + xhr.onload = () => { + if(xhr.status == 200) { + const data = JSON.parse(xhr.responseText) + if(data.result == 'sucess') { + alert('사용이 가능한 아이디입니다.') + document.input_form.id_chk.value = "1" + }else if(data.result == 'fail') { + alert('이미 사용 중인 아이디입니다. 다른 아이디를 입력해 주세요.') + document.input_form.id_chk.value = "0" + f_id.value = '' + f_id.focus() + } + } + + } + + }) + + // 가입 버튼 클릭 시 비밀번호 일치 체크 + const btn_submit = document.querySelector("#btn_submit") + btn_submit.addEventListener("click", () => { + const f = document.input_form + if (f.id.value == '') { + alert('아이디를 입력해 주세요.') + f.id.focus() + return false + } + // 아이디 중복 체크 여부 + if (f.id_chk.value == 0) { + alert('아이디 중복확인이 필요합니다.') + return false + } + // 비밀번호 입력 여부 + if (f.f_pwd.value == '') { + alert('비밀번호를 입력하세요.') + f.f_pwd.focus() + return false + } + if (f.f_pwd2.value == '') { + alert('비밀번호 확인이 필요합니다.') + f.f_pwd2.focus() + return false + } + + // 비밀번호 일치 여부 + if (f.f_pwd.value != f.f_pwd2.value) { + alert('비밀번호가 일치하지 않습니다.') + //f.f_pwd.value = '' + f.f_pwd2.value = '' + f.f_pwd2.focus() + return false + } + + }) + +}) \ No newline at end of file diff --git a/member_input.php b/member_input.php index 97400c5..88bf0c7 100644 --- a/member_input.php +++ b/member_input.php @@ -7,29 +7,34 @@ if (!isset($_POST['chk']) || $_POST['chk'] != '1') { // "); } +$js_array = ['js/member_input.js']; + include 'header.php'; ?>

회원가입

- + +
+ +
- +
- +
- +
- +
@@ -38,7 +43,7 @@ include 'header.php'; - +
@@ -46,17 +51,17 @@ include 'header.php';
- +
- +
- +
@@ -69,10 +74,12 @@ include 'header.php';
- - + +
+
+
id_exists($id)) { + + die(json_encode(['result' => 'fail'])); + +}else { + + die(json_encode(['result' => 'sucess'])); + +} \ No newline at end of file diff --git a/stipulation.php b/stipulation.php index 2a66013..551b259 100644 --- a/stipulation.php +++ b/stipulation.php @@ -1,4 +1,10 @@ - +

회원 약관 및 개인정보 취급방침 동의"