/
insert.php
66 lines (59 loc) · 1.66 KB
/
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
65
66
<meta charset="euc-kr">
<?
function Hashed($ip_pass, $salt)
{
$arr = array();
$arr[0] = $ip_pass;
$arr[1] = $salt;
$hashedPW = implode($arr);
$hashedPW = md5($hashedPW);
//echo($hashedPW);
return $hashedPW;
}
$regist_day=date("Y-m-d (H:i)"); // 현재 시간(년-월-일-시-분) 저장
$ip=$REMOTE_ADDR; // 방문자의 IP 주소 저장
$connect=mysqli_connect("localhost", "root", "apmsetup", "Task");
if (mysqli_connect_errno()) {
die('Connect Error: '.mysqli_connect_error());
}
$sql="select * from student_list where Mail='$email'";
$result = mysqli_query($connect,$sql);
$exist_id=mysqli_num_rows($result); //넘버 받아오기
if($exist_id)
{
echo("
<script>
window.alert('exist ID.')
history.go(-1)
</script>
");
exit;
}
else
{
if($passwd!=$passwd_confirm)
{
echo("
<script>
window.alert('Please check re-password.')
history.go(-1)
</script>
");
exit;
}
else
{ // 레코드 삽입 명령을 $sql에 입력
$salt = mt_rand(1000, 9999);
$hashed=Hashed($passwd, $salt);
$sql="INSERT INTO student_list (Name, Nick, Mail, HashedPW, Salt, loginCount) ";
$sql.="values('$name', '$nick', '$email', '$hashed', '$salt', 0)";
mysqli_query($connect,$sql); // $sql 에 저장된 명령 실행
}
}
mysqli_close($connect); // 데이터베이스 연결 끊기
echo ("
<script>
location.href = '../index.html';
</script>
");
?>