ID/Password 중복 및 입력여부 확인
This commit is contained in:
parent
de9583cfed
commit
921b3f042b
@ -10,8 +10,13 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"
|
||||||
integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"
|
integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<script src="js/member.js?v=<?php echo date('YmdHis'); ?>"></script>
|
<?php
|
||||||
|
if(isset($js_array)) {
|
||||||
|
foreach($js_array AS $var) {
|
||||||
|
echo '<script src="'.$var.'?v='. date('YmdHis') .'"></script>' .PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -19,7 +19,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
const f = document.stipulation_form
|
const f = document.stipulation_form
|
||||||
f.chk.value = 1
|
f.chk.value = 1
|
||||||
f.submit()
|
f.submit()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
80
js/member_input.js
Normal file
80
js/member_input.js
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
@ -7,29 +7,34 @@ if (!isset($_POST['chk']) || $_POST['chk'] != '1') {
|
|||||||
// </script>");
|
// </script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$js_array = ['js/member_input.js'];
|
||||||
|
|
||||||
include 'header.php';
|
include 'header.php';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<main class="w-50 mx-auto border rounded-5 p-5">
|
<main class="w-50 mx-auto border rounded-5 p-5">
|
||||||
<h1 class="text-center">회원가입</h1>
|
<h1 class="text-center">회원가입</h1>
|
||||||
|
|
||||||
|
<form name="input_form" method="post" enctype="multipart/form-data" action="pg/member_process.php">
|
||||||
|
<input type="hidden" name="mode" value="input">
|
||||||
|
<input type="hidden" name="id_chk" value="0">
|
||||||
<div class="d-flex gap-2 align-items-end">
|
<div class="d-flex gap-2 align-items-end">
|
||||||
<div class="flex-grow-1">
|
<div class="flex-grow-1">
|
||||||
<label for="f_id">아이디</label>
|
<label for="f_id">아이디</label>
|
||||||
<input typ="text" class="form-control" id="f_id" placeholder="아이디를 입력하세요">
|
<input typ="text" name="id" class="form-control" id="f_id" placeholder="아이디를 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-secondary"> 아이디 중복확인 </button>
|
<button type="button" class="btn btn-secondary" id="btn_id_check"> 아이디 중복확인 </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex mt-3 gap-2 justify-content-between">
|
<div class="d-flex mt-3 gap-2 justify-content-between">
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<label for="f_pwd" class="form-label">비밀번호</label>
|
<label for="f_pwd" class="form-label">비밀번호</label>
|
||||||
<input typ="pwd" class="form-control" id="f_pwd" placeholder="비밀번호를 입력하세요">
|
<input typ="password" name="f_pwd" class="form-control" id="f_pwd" placeholder="비밀번호를 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<label for="f_pwd2" class="form-label">비밀번호 확인</label>
|
<label for="f_pwd2" class="form-label">비밀번호 확인</label>
|
||||||
<input typ="pwd" class="form-control" id="f_pwd2" placeholder="비밀번호를 입력하세요">
|
<input typ="password" name="f_pwd2" class="form-control" id="f_pwd2" placeholder="비밀번호를 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -38,7 +43,7 @@ include 'header.php';
|
|||||||
<label for="f_email">이메일</label>
|
<label for="f_email">이메일</label>
|
||||||
<input typ="text" class="form-control" id="f_email" placeholder="이메일을 입력하세요">
|
<input typ="text" class="form-control" id="f_email" placeholder="이메일을 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-secondary"> 이메일 중복확인 </button>
|
<button type="button" class="btn btn-secondary"> 이메일 중복확인 </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex gap-2 mt-3 align-items-end">
|
<div class="d-flex gap-2 mt-3 align-items-end">
|
||||||
@ -46,17 +51,17 @@ include 'header.php';
|
|||||||
<label for="f_zipcode">우편번호</label>
|
<label for="f_zipcode">우편번호</label>
|
||||||
<input type="text" name="zipcode" id="zipcode" class="form-control" maxlength="5" minlength="5">
|
<input type="text" name="zipcode" id="zipcode" class="form-control" maxlength="5" minlength="5">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-secondary">우편번호 찾기</button>
|
<button type="button" class="btn btn-secondary">우편번호 찾기</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex mt-3 gap-2 justify-content-between">
|
<div class="d-flex mt-3 gap-2 justify-content-between">
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<label for="f_addr1" class="form-label">주소</label>
|
<label for="f_addr1" class="form-label">주소</label>
|
||||||
<input typ="pwd" class="form-control" id="f_addr1" placeholder="주소를 입력하세요">
|
<input typ="text" class="form-control" id="f_addr1" placeholder="주소를 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
<div class="w-50">
|
<div class="w-50">
|
||||||
<label for="f_addr2" class="form-label">상세주소</label>
|
<label for="f_addr2" class="form-label">상세주소</label>
|
||||||
<input typ="pwd" class="form-control" id="f_addr2" placeholder="상세주소를 입력하세요">
|
<input typ="text" class="form-control" id="f_addr2" placeholder="상세주소를 입력하세요">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -69,10 +74,12 @@ include 'header.php';
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3 d-flex gap-2">
|
<div class="mt-3 d-flex gap-2">
|
||||||
<button class="btn btn-primary flex-grow-1">가입확인</button>
|
<button type="button" class="btn btn-primary flex-grow-1" id="btn_submit">가입확인</button>
|
||||||
<button class="btn btn-secondary flex-grow-1">가입취소</button>
|
<button type="button" class="btn btn-secondary flex-grow-1">가입취소</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
18
pg/member_process.php
Normal file
18
pg/member_process.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include '../config/dbconfig.php'; //상대경로
|
||||||
|
include '../config/member.php';
|
||||||
|
|
||||||
|
$mem = new Member($db);
|
||||||
|
|
||||||
|
$id = $_POST['id'] ?? '';
|
||||||
|
|
||||||
|
if($mem->id_exists($id)) {
|
||||||
|
|
||||||
|
die(json_encode(['result' => 'fail']));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
die(json_encode(['result' => 'sucess']));
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,10 @@
|
|||||||
<?php include 'header.php'; ?>
|
<?php
|
||||||
|
|
||||||
|
$js_array = [ 'js/member.js'];
|
||||||
|
|
||||||
|
include 'header.php';
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<h1 class="text-center mt-5">회원 약관 및 개인정보 취급방침 동의"</h1>
|
<h1 class="text-center mt-5">회원 약관 및 개인정보 취급방침 동의"</h1>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user