-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15-3-2_insert.php
64 lines (52 loc) · 1.69 KB
/
15-3-2_insert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include_once "./15-1_connectDB.php";
//POST방식으로 전달받은 값 확인
echo "<pre>";
var_dump($_POST);
//이름 검증
if($_POST['userName'] == '' || $_POST['userName'] == null){
echo "해당값을 사용할 수 없습니다. 1";
exit;
}
$userName = $_POST['userName'];
//앞 뒤 공백 제거노
$uesrName = trim($userName);
//쿼리문의 따옴표 처리 위해 real_escape_string 메소드 사용
$userName = $dbConnect->real_escape_string($userName);
//아이디 검증
if($_POST['userId'] == '' || $_POST['userId'] == null){
echo "해당값을 사용할 수 없습니다. 2";
exit;
}
$userId = $_POST['userId'];
$userId = trim($userId);
$userId = $dbConnect->real_escape_string($userId);
//비밀번호 검증
if($_POST['userPw'] == '' || $_POST['userPw'] == null){
echo "해당값을 사용할 수 없습니다. 3";
exit;
}
//비밀번호 암호화
$userPw = sha1("everdevel".$_POST['userPw']);
if($_POST['userGender'] == 'm' || $_POST['userGender'] == 'w'){
$userGender = $_POST['userGender'];
}else{
echo "해당값을 사용할 수 없습니다. 4";
exit;
}
//이메일 유효성 검사
$emailCheck = filter_var($_POST['userEmail'], FILTER_VALIDATE_EMAIL);
if($emailCheck == false){
echo "해당값을 사용할 수 없습니다. 5";
exit;
}
$email = $_POST['userEmail'];
$sql = "INSERT INTO myMember(userId, name, password, gender, email) VALUES";
$sql .= "('{$userId}', '{$userName}', '{$userPw}', '{$userGender}', '{$email}')";
$res = $dbConnect->query($sql);
if($res){
echo '회원 가입 정보 입력 완료';
}else{
echo '회원 가입 정보 입력 실패';
}
?>