-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot.php
136 lines (129 loc) · 3.81 KB
/
forgot.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
<?php
include ("includes/header.php");
include ("includes/config.php");
include ("includes/functions.php");
$msg3 = '';
$msg4 = '';
$msg5 = '';
$msg6 = '';
$Email = '';
$dob = '';
$dob_ = '';
$Password1 = '';
$Password_ = '';
$Password = '';
if(isset($_POST['submit'])){
$Email = $_POST['Email'];
$dob = $_POST['dob'];
$Password = $_POST['Password'];
$cPassword = $_POST['cPassword'];
if (empty($Email)) {
$msg3 = "<div class='error'> Email field cannot be empty</div>";
}
elseif (!filter_var($Email,FILTER_VALIDATE_EMAIL)) {
$msg3 = "<div class='error'>Enter the registered Email</div>";
}
elseif (empty($dob)) {
$msg4 = "<div class='error'> Enter your date of birth</div>";
}
elseif (empty($Password)) {
$msg5 = "<div class='error'> Please enter a password</div>";
}
elseif (strlen($Password)<5) {
$msg5 = "<div class='error'> Password must contain atleast 5 characters</div>";
}
elseif (strcmp($Password, $cPassword)!=0) {
$msg5 = "<div class='error'> Retype your password correctly</div>";
}
else if (Email_exists($Email,$conn)){
$result = mysqli_query($conn,"select dob from registration where Email = '$Email'");
$retrieve = mysqli_fetch_array($result);
$dob1 = $retrieve['dob'];
if(strcmp($dob, $dob1)==0){
$Password1 = md5($Password);
$res = mysqli_query($conn,"update registration set Password = '$Password1'");
$msg6 = "<div class='success'>Password updated successfully</div>";
}
else{
$msg4 = "<div class='error'>Dob incorrect</div>";
}
}
else
{
$msg3 = "<div class='error'>Email does not exist</div>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Forgot Password</title>
<link href="https://fonts.googleapis.com/css?family=Crete+Round&display=swap" rel="stylesheet">
<style type="text/css">
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Crete Round', serif;
}
#bgimg{
width: 100%;
height: 100vh;
background-image: repeating-radial-gradient(#0000ff 5%,#0040ff 10%,#00c0ff 15%);
}
.jumbotron{
margin-top: 20px;
padding-top: 20px;
padding-bottom: 20px;
background-image: linear-gradient(#00c0ff,#0040ff);
color:white;
}
.login-form{
background-image: linear-gradient(#00c0ff,#48cccd);
}
.error{
color:red;
font-weight: bold;
text-shadow: 0.8px 0.8px #ffffff;
text-indent: 0.5px;
}
.success{
color:#006400;
text-shadow: 0.8px 0.8px #000000;
text-indent: 0.5px;
}
h3{
text-align: center;
color:blue;
text-shadow: 0.9px 0.9px white;
font-weight: bold;
}
</style>
</head>
<body id = "bgimg">
<div class="container">
<div class="login-form col-md-4 offset-md-4">
<div class="jumbotron">
<h3>Forgot Password</h3><br>
<?php echo $msg6; ?>
<form method="post">
<div class="form-group">
<label>Email: </label>
<input type="email" name="Email" placeholder="Enter your Email" class="form-control" value="<?php echo $Email ?>"><?php echo $msg3 ?>
<br>
<label>Date of Birth: </label>
<input type="date" name="dob" placeholder="Enter your date of birth"
class="form-control" value="<?php echo $dob ?>"><?php echo $msg4 ?><br>
<label>Password: </label>
<input type="password" name="Password" placeholder="Enter your new password" class="form-control"><?php echo $msg5 ?><br>
<label>Confirm Password: </label>
<input type="password" name="cPassword" placeholder="Retype your new password" class="form-control"><?php echo $msg5 ?><br>
<center><input type="submit" name="submit" class="btn btn-success" value="Submit"></center><br>
<center><a href="userlogin.php" class="text-white"><- Back to login page</a></center><br>
</div>
</form>
</div>
</div>
</div>
</body>
</html>