-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
363 lines (348 loc) · 10.6 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<?php
session_start();
if(isset($_SESSION['user']))
{
require_once("dbconnect.php");
$email=$_SESSION['user'];
$qb=mysqli_query($con,"SELECT id FROM user WHERE email='$email'");
$qbrow=mysqli_fetch_array($qb);
header("location:home.php?u=".$qbrow[0]);
}
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="SHORTCUT ICON" href="images/icon/logo.ico">
<title>Sign Up</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" media="all" href="css/bootstrap.min.css">
<script src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/bootstrap-filestyle.min.js"> </script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src="js/wow.min.js"></script>
<script>
new WOW().init();
</script>
</head>
<style>
body
{ background-image:url(images/Friends.jpg) ;
background-repeat:no-repeat;
background-attachment:scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.posi
{
margin-top:35px;
margin-left:20px;
padding:10px;
}
.modal-header, .close
{
background: linear-gradient(to right, #900048 , #B73D7A);
color:white !important;
text-align: center;
font-size: 30px;
}
.modal-footer a
{
color:#B8005C;
}
.btn-danger
{
background: linear-gradient(to right, #55002A , #FF0B85);
}
#login { color:#B8005C;}
#centered
{
display: block;
margin-left: auto;
margin-right: auto;
box-shadow: 5px 5px 5px rgba(0,0,0,0.75);
}
#rankethon
{
margin-top:20px;
}
.foot
{
background-color:black;
color:white;
text-align:center;
padding:10px;
}
.btn
{
box-shadow: 0px 2px 1px #7b7b52;
}
a:hover,a:focus,a:visited{
text-decoration:none;
}
</style>
<body>
<!--Modal-->
<div class="container">
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header" style="padding=35px 50px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4><span class="glyphicon glyphicon-lock" aria-hidden="true"></span><strong> Login</strong></h4>
</div>
<div class="modal-body" style="padding:40px 50px;">
<form role="form" action="" method="POST">
<div class="form-group">
<label for="usn"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Email</label>
<input type="text" class="form-control" name="uname" id="usn" placeholder="Enter Email">
</div>
<div class="form-group">
<label for="pass"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> Password</label>
<input type="password" class="form-control" name="upass" placeholder="Enter password">
</div>
</div>
<div class="modal-footer" style="padding:10px 20px;">
<button type="submit" name="login" class="btn btn-danger pull-left"><strong> Login</strong></button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!--End of Modal-->
<?php
if(isset($_POST['login']))
{
require_once("dbconnect.php");
$emailid=$_POST['uname'];
$password=md5($_POST['upass']);
$query="SELECT * FROM user WHERE email='{$emailid}'";
$result=mysqli_query($con,$query);
$row=mysqli_fetch_array($result);
$num=mysqli_num_rows($result);
?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>
<?php
if($num==0)
echo "Email doesnt exist!";
else
{
$dbpass=$row[4];
if($password==$dbpass)
{
if(!(isset($_SESSION)))
session_start();
$id=$row[0];
$_SESSION['user']=$emailid;
header("location:home.php?u=$id");
}
else
echo "Username password does not match";
}
?>
</strong> .Please try again! <?php echo $num;?>
</div>
<?php
}
?>
<!--content-->
<div class="posi">
<div class="container-fluid">
<div class="row">
<div class="col-md-5" style="color:white;">
<br>
<img src="images/rank.jpg" width="170" id="centered" class="img-responsive wow flip" height="170" style="border-radius:25px;">
<br>
<h1 style="text-align:center;" class="wow pulse">Welcome to Rankethon</h1>
<h4 style="text-align:center;" class="wow pulse">Now express yourself with liberty and be a part of your friend's happy and sad moments because being social matters. </h4>
</div>
<div>
<div class="col-md-2">
</div>
<div class="col-md-4" style="background-color:white; opacity:0.92; line-height:45%; border-radius: 25px;">
<div class="wow fadeIn">
<br>
<h4>Already a member !<a id="login" data-toggle="modal" href="#myModal"> Login</a> </h3>
<h4>Not a member? Sign Up</h3><hr>
<!--register php-->
<?php
require_once("dbconnect.php");
if(isset($_POST['submit']))
{
$name=strip_tags(mysqli_real_escape_string($con,$_POST['name']));
$sname=strip_tags(mysqli_real_escape_string($con,$_POST['sname']));
$email=strip_tags(mysqli_real_escape_string($con,$_POST['email']));
$mnumber=strip_tags(mysqli_real_escape_string($con,$_POST['mnumber']));
$pword=$_POST['pword'];
$rpword=$_POST['rpword'];
//error checking
$e=0;$flag=1;
//check for name
$regex="/^[a-z ]+$/i";
if(!preg_match($regex,$name))
{
echo '<font color=red><b>Name is invalid</b></font><br>';
$flag=0;
}
//check for surname
$regex="/^[a-z ]+$/i";
if(!preg_match($regex,$sname))
{
echo "<br><font color=red><b>Surname is invalid!</b></font><br>";
$flag=0;
}
//Check for email
$regex="/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/";
if(preg_match($regex,$email))
{
$result = mysqli_query($con,"SELECT * FROM user WHERE email = '{$email}'");
if(!$result)
{
die(mysqli_error($con));
$flag=0;
}
if(mysqli_num_rows($result) > 0)
{
die("<br><font color=red><b>Email already in DB </b></font><br>");
$flag=0;
}
}
else
{
echo "<br><font color=red><b>Email is invalid!</b></font><br>";
$flag=0;
}
//check for phone number
$regex="/^[789][0-9]{9}$/";
if(!preg_match($regex,$mnumber))
{
echo "<br><font color=red><b>Phone number is invalid!</b></font><br>";
$flag=0;
}
//check for password
$str_len = strlen($pword);
$str_len2 = strlen($rpword);
if(($str_len == 0)||($str_len2 == 0))
{
echo "<br><font color=red><b>Please enter valid password!</b></font><br>";
$flag=0;
}
if(($str_len <= 6)||($str_len2 <= 6))
{
echo "<br><font color=red><b>Password should be more than 6 characters.</b></font><br>";
$flag=0;
}
if($pword!= $rpword)
{
echo "<br><font color=red><b>Passwords do not match!</b></font><br>";
$flag=0;
}
$gender=NULL;
if (!isset($_POST["gender"]))
{
echo "<br><font color=red><b>Gender is Mandatory</b></font><br>";
$flag=0;
}
else
{
$gender=$_POST['gender'];
}
$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];
$fulldate=$day.'/'.$month.'/'.$year;
$pass=md5($pword);
$query="INSERT INTO user(name,sname,email,pass,mob,gen,dob) VALUES('{$name}','{$sname}','{$email}','{$pass}','{$mnumber}','{$gender}',STR_TO_DATE('{$fulldate}','%d/%M/%Y'))";
if($flag==1)
{
$ins=mysqli_query($con,$query);
$print='<div class="alert alert-success"> <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><strong>Account Created</strong> Please <a id="login" data-toggle="modal" href="#myModal">login</a> </div>';
echo $print;
}
else
echo "<br><font color=red><b>Error!</b></font><br><br>";
}
?>
<form role="form" action="" method="post">
<div class="form-group">
<label for="name">Name :</label>
<input type="text" data-toggle="tooltip" title="Name should not contain any number or special characters" data-placement="left" class="form-control" name="name" id="name" placeholder="Enter your name">
</div>
<div class="form-group">
<label for="sname">Surname :</label>
<input type="text" class="form-control" name="sname" data-toggle="tooltip" title="Surname should not contain any number or special characters" data-placement="left" placeholder="Enter your surname">
</div>
<div class="form-group">
<label for="email">Email-id :</label>
<input type="text" class="form-control" data-toggle="tooltip" title="You will use this to login" data-placement="left" name="email" placeholder="Enter Email-id">
</div>
<div class="form-group">
<label for="pword">Password :</label>
<input type="password" class="form-control" name="pword" data-toggle="tooltip" title="Be a little tricky!" data-placement="left" placeholder="Enter password [more than 6 characters]">
</div>
<div class="form-group">
<label for="rpword">Re-enter password :</label>
<input type="password" class="form-control" name="rpword" data-toggle="tooltip" title="Type the same password again" data-placement="left" placeholder="Re-type your password">
</div>
<div class="form-group">
<label for="mnumber">Mobile-No. :</label>
<input type="text" class="form-control" name="mnumber" data-toggle="tooltip" title="What's your mobile number?" data-placement="left" placeholder="Enter your mobile number">
</div>
<div class="form-group" >
<label>Gender : </label>
<input type="radio" name="gender" value="male" >Male
<input type="radio" name="gender" value="female" >Female
</div>
<div class="form-group">
<b>Date of Birth : </b>
<select name="day" value="Day">
<?php
for($i=1;$i<=31;$i++)
echo "<option>$i</option>";
?>
</select>
<select name="month">
<?php
$m=array( "","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
for($i=1;$i<=12;$i++)
echo "<option>$m[$i]</option>";
?>
</select>
<select name="year">
<?php
for($i=2015;$i>=1905;$i--)
echo "<option>$i</option>";
?>
</select>
</div>
<hr>
<button type="submit" name="submit" class="btn btn-danger btn-block" style="font-size:large"><b>Create Account</b></button>
<br>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!--End of content-->
<!--footer-->
<div class="foot">
<div class="container-fluid ">
<p>© Copyright Tech Wizards </p>
</div>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</body>
</html>