-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot-password.php
157 lines (139 loc) · 4.94 KB
/
forgot-password.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();
require_once "database_connect.php";
if(isset($_POST['reset'])){
$email =$_POST['email'];
$check_email = "SELECT * FROM owner WHERE email='$email'";
$check_email2 = "SELECT * FROM manager WHERE email='$email'";
$run_sql = mysqli_query($conn, $check_email);
$run_sql2 = mysqli_query($conn, $check_email2);
if(mysqli_num_rows($run_sql) > 0){
$code = rand(9999999, 1111111);
$new = "P".$code;
$insert_code = "UPDATE owner SET pass = '$new' WHERE email = '$email'";
$run_query = mysqli_query($conn, $insert_code);
if($run_query){
$subject = 'New Password';
$message = 'Your new password code is: '.$new;
$sender = "From: HappyPaws <[email protected]>\r\n";
$to= $email;
mail($to, $subject, $message, $sender);
header('location:login.php');
}}
else if(mysqli_num_rows($run_sql2) > 0){
$code2 = rand(9999999, 1111111);
$new2 = "P".$code2;
$insert_code2 = "UPDATE manager SET password = '$new2' WHERE email = '$email'";
$run_query2 = mysqli_query($conn, $insert_code2);
if($run_query2){
$subject = "New Password";
$message = 'Your new password code is: '.$new2;
$sender = "From: HappyPaws <[email protected]>\r\n";
$to= $email;
mail($to, $subject, $message, $sender);
header('location:login.php');
}}
else
header("Location: forgot-password.php?error=Wrong");
mysqli_close($conn);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Happy Paws Clinic</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"/>
<style> .mainRESET {
background-color: white;
border-top: 10px solid rgb(4, 73, 138);
border-bottom: 10px solid rgb(4, 73, 138);
width: 400px;
overflow: hidden;
text-align: center;
margin: auto ;
margin-top: 85px;
padding: 45px;
padding-bottom: -20px;
padding-right: 80px;
box-shadow: 1px 1px 108.8px 1px rgb(99, 108, 138);
border-radius: 15px ;
}
Body
{
background-image: url(image/design.png);
background-size: cover;
font-family: 'Times New Roman', Times, serif;
color: rgb(4, 73, 138);
}
.logo{ position: relative;
padding: 0%;
margin-top: -30px ;}
.form{
position: relative;
border: 0;
outline-color: #0b4b8b;
box-shadow: none;
display: block;
border-bottom: 1px solid rgb(4, 73, 138);
width: 100%;
height: 30px;
font-family: 'Times New Roman', Times, serif;
font-size: medium;
font-weight: 500;
padding-left: 25px;
transition: all 0.3s ease;
padding-bottom: -20px;
margin-bottom: auto;
}
.icon{
position: absolute;
margin-top: -13px; margin-left: 2px;
transform: translateY(-50%);
color: #708090;
}
.btn{
position: relative;
border:0;
color: rgb(4, 73, 138) ;
border-radius: 100px;
width: 340px;
height: 49px;
font-size: 20px;
font-family: 'Times New Roman', Times, serif;
top: 79%;
margin-bottom: 1.5px;
cursor: pointer; }
.btn:hover{
background-image: url(image/button.jpg);
color: white;}
.error{
color: red;
font-size: 13px;
font-family: sans-serif;
}
</style>
</head>
<body>
<div class="mainRESET">
<form action="forgot-password.php" method="post">
<img class="logo" src="image/logo.png" width="260" height="130">
<p style="color: #708090; font-family: 'Courier New', Courier, monospace; font-size: medium; margin-top: -10px; margin-bottom: 10px;"><b>Pawsitively Great Care</b></p>
<br>
<h2>Forgot your password? </h2>
<p style="color: #708090; font-family: 'Courier New', Courier, monospace; font-size: small; font-weight: 600;">No worries, Enter your email address and we'll send you a new password which you can change it later </p>
<br><br>
<input class="form" name ="email" type ="text" placeholder="Enter Email" size= "40" maxlength="30" required >
<div class="icon"><i class="fas fa-mail-bulk"></i></div>
<?php
$error= " http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if(strpos($error , "error=Wrong")==true){
echo "<p class='error'> Wrong email, try again!</p>";
}
?>
<br>
<input class="btn" type="submit" name="reset" value="Send Email">
<br>
</form>
<a href="login.php" > <button class="btn">Back </button> <a></div>
</body>
</html>