-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
142 lines (129 loc) · 5.17 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
<?php
session_start();
if (isset($_SESSION['id'])) {
header('location: ./user-home.php');
} else {
include './connection.php';
$err =' ';
if (isset($_POST['submit'])) {
// echo 'a';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
$security_question = $_POST['security-question'];
$security_answer = strtolower($_POST['security-answer']);
if ($password == $repassword) {
print $err;
if (strlen($password) < 8 || strlen($password) > 16) {
$err = 'password must be of lenght between 8-16';
} elseif (!preg_match ("/[0-9]/", $password)) {
$err = 'password must contain at least one number';
} elseif (!preg_match("/[a-z]/", $password)) {
$err = 'password must contain one small case letter';
} elseif (!preg_match("/[A-Z]/", $password)) {
$err = 'password must contain at least one capital letter';
} elseif (!preg_match("/[!@#%$]/", $password)) {
$err = 'password must have either of !, @, #, %, $';
} else {
$err ='nice password';
$checkEmailQuery = "SELECT email FROM registeration WHERE email = '$email'";
$checkEmai = $con -> query($checkEmailQuery);
if ($checkEmai -> num_rows > 0) {
$err = 'email already exists';
} else {
$password = md5($password);
$insertQuery = "INSERT INTO registeration (fname, lname, email, mobile, password, status, securityQuestion, securityAnswer) VALUES ('$fname', '$lname', '$email', '$mobile', '$password', 'active', '$security_question', '$security_answer')";
$insert = $con -> query($insertQuery);
if ($insert) {
// print 'Yee-haw';
print $err;
header('location: ./signup.php');
}
}
}
} else {
$err = 'password do not match!';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
<div class="container">
<form class="s 12" method="POST">
<div class="row">
<div class="input-field col s6">
<input id="fname" type="text" class="validate" name="fname" required>
<label for="fname">First Name</label>
</div>
<div class="input-field col s6">
<input id="lname" type="text" class="validate" name="lname" required>
<label for="lname">Last Name</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="email" type="text" class="validate" name="email" required>
<label for="email">Email</label>
</div>
<div class="input-field col s6">
<input id="mobile" type="text" class="validate" name="mobile" maxlength="10" required>
<label for="mobile">Mobile</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<select name="security-question" required>
<option value="" disabled selected>Choose your option</option>
<option value="What is you birth place?">What is you birth place?</option>
<option value="What is your pet's name?">What is your pet's name?</option>
<option value="What is vehicle's registeration number?">What is vehicle's registeration number?</option>
</select>
<label>Security Question</label>
</div>
<div class="input-field col s6">
<input id="security-answer" type="text" class="validate" name="security-answer" required>
<label for="security-answer">Answer</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="password" type="password" class="validate" name="password" required>
<label for="password">Password</label>
</div>
<div class="input-field col s6">
<input id="repassword" type="password" class="validate" name="repassword" required>
<label for="repassword">Re enter password</label>
</div>
</div>
<div class="row">
<div class="center">
<input type="submit" value="Submit" class="input-field btn" name="submit">
<?php
if ($err != ' ') {
echo '<br>' . $err;
}
echo '<br>';
?>
<span>Already have an account? Login <a href="./index.php">here</a>.</span>
</div>
</div>
</form>
</div>
<!-- Compiled and minified JavaScript -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="./main.js"></script>
</body>
</html>