-
Notifications
You must be signed in to change notification settings - Fork 1
/
sign-up.php
165 lines (150 loc) · 3.03 KB
/
sign-up.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
164
165
<?php
session_start();
include 'config.php'
?>
<?php
$error="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
$name = $_POST['name'];
$dob = $_POST['dob'];
$sex = $_POST['sex'];
$phone = $_POST['phone'];
$email = $_POST['email'];
if ($conn->query("select UserName from Users where UserName = '".$username."';")->num_rows !== 0) {
$error = "Username taken. Enter different username.";
}
elseif ($conn->query("select Phone from Users where Phone = ".$phone.";")->num_rows !== 0) {
$error = "Account exists with given Phone number.";
}
elseif ($conn->query("select Email from Users where Email = '".$email."';")->num_rows !== 0) {
$error = "Account exists with given Email Address.";
}
elseif ($password !== $_POST['confirmpassword']) {
$error = "Password does not match.";
}
else {
$conn->query("insert into Users (FullName, DoB, Sex, Phone, Email, UserName, Password)
values ('$name', '$dob', '$sex', '$phone', '$email', '$username', '$password');");
$_SESSION['username'] == $username;
header("location:profile.php");
}
}
?>
<!DOCTYPE html>
<html>
<?php
$title="Sign Up : Heka RX";
include 'head.php';
?>
<body>
<?php
$activeNavTabs = array("Profile");
include 'template.php';
?>
<main>
<div class="ad-column">
<?php
$adType = "desktop";
include 'ad.php';
?>
</div>
<div class="content-column">
<div class="form-container">
<h2>Sign Up</h2>
<form
method="post"
action="<?php
echo htmlspecialchars($_SERVER['PHP_SELF'])
;?>"
>
<div>
<label for="name">Name</label>
<input
type="text"
name="name"
id="name"
required
>
</div>
<div>
<label for="dob">Date of Birth</label>
<input
type="date"
name="dob"
id="dob"
>
</div>
<div>
<label for="sex">Sex</label>
<select name="sex" id="sex">
<option value="" hidden></option>
<option value="F">Female</option>
<option value="M">Male</option>
</select>
</div>
<div>
<label for="phone">Phone No.</label>
<input
type="tel"
name="phone"
id="phone"
required
>
</div>
<div>
<label for="email">Email</label>
<input
type="email"
name="email"
id="email"
required
>
</div>
<div>
<label for="username">User Name</label>
<input
type="text"
name="username"
id="username"
required
>
</div>
<div>
<label for="password">Password</label>
<input
type="password"
name="password"
id="password"
required
>
</div>
<div>
<label for="confirmpassword">
Confirm Password
</label>
<input
type="password"
name="confirmpassword"
id="confirmpassword"
required
>
</div>
<div>
<input type="submit" value="Sign Up">
<?php echo $error ?>
</div>
</form>
</div>
Already have an account? <a href="./login.php">Login</a>
</div>
<div class="ad-column">
<?php
$adType = "desktop";
include 'ad.php';
?>
</div>
</main>
</body>
</html>