forked from QuarantineMeals/QuarantineMeals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_reg.php
235 lines (207 loc) · 8.96 KB
/
user_reg.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
include('config/db_connect.php');
session_start();
$user_name = $user_address = $user_city = $user_number = $user_mail = $user_password = "";
$user_name_error = $user_address_error = $user_city_error = $user_password_error = $user_number_error = $user_mail_error = "";
$is_error = false;
if (isset($_POST['user_reg'])) {
$user_name = mysqli_real_escape_string($conn, $_POST['user_name']);
$user_address = mysqli_real_escape_string($conn, $_POST['user_address']);
$user_city = mysqli_real_escape_string($conn, $_POST['user_city']);
$user_number = mysqli_real_escape_string($conn, $_POST['user_number']);
$user_mail = mysqli_real_escape_string($conn, $_POST['user_mail']);
$user_password = mysqli_real_escape_string($conn, $_POST['user_password']);
if (empty($user_name)) {
$user_name_error = "Please enter your name";
$is_error = true;
}
if (empty($user_address)) {
$user_address_error = "Please enter your address";
$is_error = true;
}
if (empty($user_password)) {
$user_password_error = "Please enter your password";
$is_error = true;
} else if (strlen($user_password) < 8) {
$user_password_error = "Password should be >=8 characters";
$is_error = true;
}
if (empty($user_city)) {
$user_city_error = "Please enter your City";
$is_error = true;
} else if (!preg_match("/^[a-zA-z]*$/", $user_city)) {
$user_city_error = "Enter only Alphabets and whitespaces";
$is_error = true;
}
if (empty($user_number)) {
$user_number_error = "Please enter your Mobile number";
$is_error = true;
} else if (!filter_var($user_number, FILTER_VALIDATE_INT)) {
$user_number_error = "Mobile number should be numbers";
$is_error = true;
}
if (empty($user_mail)) {
$user_mail_error = "please enter your email";
$is_error = true;
} else if (!filter_var($user_mail, FILTER_VALIDATE_EMAIL)) {
$user_mail_error = "Invalid email format";
$is_error = true;
}
if ($is_error == false) {
$sql = "INSERT INTO user (user_password,user_name,user_mail,user_address,user_number,user_city) VALUES ('$user_password','$user_name','$user_mail','$user_address','$user_number','$user_city')";
$result = mysqli_query($conn, $sql);
if ($result) {
header('Location: admin/');
} else {
echo mysqli_error($conn);
}
}
}
?>
<!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>QuarantineMeals</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<!-- google fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Reggae+One&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script>
$(document).ready(function() {
$('.visibility_off').hide();
$('.suffix').click(function() {
if ($('#user_password').attr('type') == 'password') {
$('.visibility_off').show();
$('.visibility').hide();
$('#user_password').attr('type', 'text');
} else {
$('.visibility_off').hide();
$('.visibility').show();
$('#user_password').attr('type', 'password');
}
});
$("#user_password").focus(function() {
$('.suffix').css('color', '#ff9800');
});
$("#user_password").focusout(function() {
$('.suffix').css('color', 'black');
});
});
</script>
<style>
.suffix {
position: absolute;
float: right;
right: 1rem !important;
top: 1rem;
}
.suffix:hover {
cursor: pointer;
}
.input-field {
position: relative;
padding-bottom: 30px !important;
}
.suffix {
position: absolute;
float: right;
right: 1rem !important;
top: 1rem;
}
.suffix:hover {
cursor: pointer;
}
.input-field label {
color: orange;
}
/* label focus color */
.input-field input:focus+label {
color: orange !important;
}
/* label underline focus color */
.input-field input:focus {
border-bottom: 1px solid orange !important;
box-shadow: 0 1px 0 0 orange !important;
}
/* icon prefix focus color */
.input-field .suffix .active {
color: orange !important;
}
[type="checkbox"].filled-in:checked+span:not(.lever):after {
background-color: orange;
border: 2px solid orange;
}
[type="radio"]:checked+span:after,
[type="radio"].with-gap:checked+span:after {
background-color: orange;
}
[type="radio"]:checked+span:after,
[type="radio"].with-gap:checked+span:before,
[type="radio"].with-gap:checked+span:after {
border: 2px solid orange;
}
body {
background: whitesmoke;
}
</style>
</head>
<body>
<section class="section">
<h3 class="center">Sign-up as a user</h3>
<div class="container">
<form action="user_reg.php" method="POST" class="section">
<div class="row">
<div class="input-field col s12 m6">
<input type="text" id="user_name" name="user_name" value="<?php echo htmlspecialchars($user_name) ?>">
<label for="user_name">Enter your name</label>
<div class="red-text"><?php echo htmlspecialchars($user_name_error) ?></div>
</div>
<div class="input-field col s12 m6">
<input type="text" id="user_number" name="user_number" value="<?php echo htmlspecialchars($user_number) ?>">
<label for="user_number">Enter your Mobile-number</label>
<div class="red-text"><?php echo htmlspecialchars($user_number_error) ?></div>
</div>
</div>
<div class="row">
<div class="input-field col s12 m6">
<input type="text" id="user_city" name="user_city" value="<?php echo htmlspecialchars($user_city) ?>">
<label for="user_city">Enter your City</label>
<div class="red-text"><?php echo htmlspecialchars($user_city_error) ?></div>
</div>
<div class="input-field col s12 m6">
<input type="text" id="user_address" name="user_address" value="<?php echo htmlspecialchars($user_address) ?>">
<label for="user_address">Enter your Address</label>
<div class="red-text"><?php echo htmlspecialchars($user_address_error) ?></div>
</div>
</div>
<div class="row">
<div class="input-field col s12 m6">
<input type="text" id="user_mail" name="user_mail" value="<?php echo htmlspecialchars($user_mail) ?>">
<label for="user_mail">Enter your Email</label>
<div class="red-text"><?php echo htmlspecialchars($user_mail_error) ?></div>
</div>
<div class="input-field col s12 m6">
<i class="material-icons suffix visibility_off ">visibility_off</i>
<i class="material-icons suffix visibility">visibility</i>
<input type="password" id="user_password" name="user_password" value="<?php echo htmlspecialchars($user_password) ?>">
<label for="user_password" class="active">Enter Password</label>
<div class="red-text">
<?php echo $user_password_error ?>
</div>
</div>
</div>
<div class="center">
<input type="submit" class="btn orange" value="submit" name="user_reg">
</div>
</form>
</div>
</section>
</body>
</html>