-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
157 lines (127 loc) · 5.4 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
<?php
session_start();
$showAlert = false;
$showError = false;
$exists = false;
include 'db_con.php';
if($_SERVER["REQUEST_METHOD"] == "POST") {
$fullName = mysqli_real_escape_string($con, $_POST["fullName"]);
$email = mysqli_real_escape_string($con, $_POST["email"]);
$mobile = mysqli_real_escape_string($con, $_POST["mobile"]);
$password = mysqli_real_escape_string($con, $_POST["password"]);
$confirmpassword = mysqli_real_escape_string($con, $_POST["confirmpassword"]);
# Password Hashing
$pass = password_hash($password, PASSWORD_DEFAULT);
$cpass = password_hash($confirmpassword, PASSWORD_DEFAULT);
# Checks if the Email is already
# associated with another email or not
$sql = "select * from register where email = '$email'";
$result = mysqli_query($con, $sql);
$num = mysqli_num_rows($result);
if ($num > 0) {
echo '<div style=" font-size: 18px; color: red;">Email Already Exist</div>';
}
else {
if($password === $confirmpassword) {
# inserts data to the database
$sql = "INSERT INTO `register` (`fullname`, `email`, `pnumber`, `fpassword`, `cpassword`) VALUES ('$fullName', '$email', '$mobile', '$pass', '$cpass')";
$result = mysqli_query($con, $sql);
if ($result) {
$showAlert = true;
}
}
else {
echo '<div style=" font-size: 18px; color: red;">Password did not match</div>';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SignUp</title>
<!-- Google reCaptcha -->
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<?php
if ($showAlert) {
echo '<div style=" font-size: 18px; color: green;">Sucessfully Created User</div>';
// header('location:index.php');
}
if ($showError) {
echo '$showError';
}
if ($exists) {
echo '$exists';
}
?>
<div class="form_layout">
<form id="form" class="form_container" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<h1>Register</h1>
<div class="field">
<input type="text" name="fullName" class="enterName" autocomplete="off" required>
<label for="fullName" class="label-name">
<span class="content-name">Full Name</span>
</label>
</div>
<div class="field">
<input type="text" name="email" class="enterEmail" autocomplete="off" required>
<label for="name" class="label-name">
<span class="content-name">Email</span>
</label>
</div>
<div class="field">
<input type="text" name="mobile" minlength="10" maxlength="10" autocomplete="off" required>
<label for="mobile" class="label-name">
<span class="content-name">Mobile</span>
</label>
</div>
<div class="field">
<input type="password" id="password" class="password" onkeyup="trigger()" name="password" autocomplete="off" required>
<label for="password" class="label-name">
<span class="content-name">Password</span>
</label>
</div>
<div class="indicator">
<span class="weak"></span>
<span class="medium"></span>
<span class="strong"></span>
</div>
<ul style="width: 88%; justify-content: right; margin: auto;">
<li>Must contain small letter and capital letters</li>
<li>Must contain numbers and characters</li>
<li>Should be atleast 8 character</li>
</ul>
<div class="field">
<input type="password" class="password" name="confirmpassword" autocomplete="off" required>
<label for="confirmpassword" class="label-name">
<span class="content-name">Confirm Password</span>
</label>
</div>
<div class="captcha">
<div class="g-recaptcha" data-sitekey="6LcOJ6QgAAAAAOIuIKA4fDfUDVTse3fICI1B-YEG" data-callback="enableBtn"></div>
</div>
<div class="btn">
<button type="submit" class="button" id="submit" disabled="disabled">
<span class="btn_text">signup</span>
</button>
<script type="text/javascript">
// JS to enable button only if captcha is solved
function enableBtn() {
document.getElementById("submit").disabled = false;
}
</script>
</div>
<div class="link">
<p>Already have an account <span><a href="./index.php" rel="noopener noreferrer">Login</a></span>? </p>
</div>
</form>
</div>
<script src="./JS/app.js"></script>
</body>
</html>