-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.php
163 lines (134 loc) · 3.54 KB
/
signup.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
require_once 'header.php';
echo <<<_END
<style>
body{
background-color: black;
}
h1 {
margin-top:75px;
color: white;
}
h2{
margin-top:5%;
font-size:30px;
color: red;
/*color:darken(#e5e5e5, 50%);*/
border-bottom:solid 1px #e5e5e5;
}
input[type="text"]
{
background: #fff;
border: 1px solid #dbdbdb;
font-size: 1.2em;
padding: .5em .5em;
border-radius: 2px;
display: inline-block;
border: none;
background: #f1f1f1;
margin-bottom: 15px;
}
input[type = "password"]
{
margin-top:15px;
background: #fff;
border: 1px solid #dbdbdb;
font-size: 1.2em;
padding: .5em .5em;
border-radius: 2px;
display: inline-block;
border: none;
background: #f1f1f1;
margin-left: 2px;
}
input[type="submit"] {
background-color: darkred;
color: white;
padding: 14px 20px;
margin: 8px 0;
margin-left:170px;
border: none;
cursor: pointer;
width: 10%;
opacity: 0.9;
}
</style>
<script>
function checkUser(user) {
if (user.value == '') {
$('#used').html(' ');
return;
}
$.post('checkuser.php', { user : user.value }, function(data) {
$('#used').html(data)
});
}
</script>
_END;
$error = $user = $pass = "";
if (isset($_SESSION['user']))
destroySession();
if (isset($_POST['user'])) {
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if ($user == "" || $pass == "")
$error = 'Not all fields were entered<br><br>';
else {
$result = queryMysql("SELECT * FROM members WHERE user='$user'");
if ($result->num_rows)
$error = 'That username already exists<br><br>';
else {
queryMysql("INSERT INTO members VALUES('$user', '$pass')");
createTable("{$user}_topMovies",
'user_id INT(6),
movie_id INT(6)');
createTable("{$user}_topTV",
'user_id INT(6),
tv_id INT(6)');
createTable("{$user}_bottomMovies",
'user_id INT(6),
movie_id INT(6)');
createTable("{$user}_bottomTV",
'user_id INT(6),
tv_id INT(6)');
createTable("{$user}_honorableMovies",
'user_id INT(6),
movie_id INT(6)');
createTable("{$user}_honorableTV",
'user_id INT(6),
tv_id INT(6)');
createTable("{$user}_watchlist_movies",
'user_id INT(6),
movie_id INT(6)');
createTable("{$user}_watchlist_tv",
'user_id INT(6),
tv_id INT(6)');
die('<h4>Account created</h4>Please Log in.</div></body></html>');
}
}
}
echo <<<_END
<h1>Welcome to the signup page</h1>
<form method='post' action='signup.php'>$error
<div data-role='fieldcontain'>
<label></label>
<h3>Create username and password</h3>
</div>
<div data-role='fieldcontain'>
<label>Username</label>
<input type='text' maxlength='16' name='user' value='$user' onBlur='checkUser(this)'>
<label></label>
<!-- <div id='used'> </div> -->
</div>
<div data-role='fieldcontain'>
<label>Password</label>
<input type='text' maxlength='16' name='pass' value='$pass'>
</div>
<div data-role='fieldcontain'>
<label></label>
<input data-transition='slide' type='submit' value='Sign Up'>
</div>
</form>
_END;
require_once 'footer.php';
?>