-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoin.php
More file actions
68 lines (55 loc) · 2.06 KB
/
join.php
File metadata and controls
68 lines (55 loc) · 2.06 KB
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
67
68
<?php
header("Content-Type:text/html;charset=utf-8");
$host = '127.0.0.1';
$user = 'root';
$pw = 'chanki';
$dbName = 'healthcare';
$port = 3306;
$mysqli = new mysqli($host, $user, $pw, $dbName,$port);
if($mysqli === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$email=$_POST['email'];
$password=md5($_POST['password']);
$userName=$_POST['userName'];
$teamName=$_POST['teamName'];
$director=$_POST['director'];
$mysqli->set_charset("utf8");
$sql_director = "select * from userinfo WHERE teamname LIKE '{$teamName}'";
$res_director = $mysqli ->query($sql_director);
$sql_id = "select * from userinfo WHERE email LIKE '{$email}'";
$res_id = $mysqli ->query($sql_id);
if($res_id->num_rows){
echo "<script> alert('이미 존재하는 아이디입니다.'); location.href='/joinpage.php'; </script>";
return;
}
$sql = "insert into userInfo (email, password ,name, teamname,director,auth)";
if($director == 'true'){
if($res_director->num_rows){
echo "<script> alert('이미 존재하는 팀에 팀장이 될 수 없습니다. 새로운 팀을 만드세요'); location.href='/index.html'; </script>";
return;
}
else{
$sql = $sql. "values('$email','$password','$userName', '$teamName','$director','true')";
}
}
else{
$sql = $sql. "values('$email','$password','$userName', '$teamName','$director','false')";
}
if(! $sql )
{
die('Could not update data: ' . mysqli_error());
}
if($mysqli->query($sql)){
echo '회원가입에 성공하셨습니다. 로그인 페이지로 이동합니다.';
echo("<script>location.replace('./index.html');</script>");
}
else{
echo '에러가 발생했습니다. 다시 한번 확인후 가입해주세요.';
echo("<script>location.replace('./index.html');</script>");
echo "Query: " . $sql . "\n";
echo "Errno: " . $mysqli->errno . "\n";
echo "Error: " . $mysqli->error . "\n";
exit;
}
?>