-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathForgotPassword.php
More file actions
162 lines (136 loc) · 4.23 KB
/
Copy pathForgotPassword.php
File metadata and controls
162 lines (136 loc) · 4.23 KB
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
<?php
session_start();
$origin = $_SESSION['origin'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Forgot Password</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/forgot_password_style.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<style>
.D{
color: grey;
}
.DJ{
padding: 20px;
}
.container {
position: relative;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); /* Change RGBA values to 0, 0, 0 for black */
animation: fadeInUp 1s ease-in-out; /* Animation */
}
@keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
#loading-spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
transition: opacity 0.5s ease;
display: none;
}
#reset:hover {
transform: scale(1.1);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<div class="D"></div>
<div class="container">
<div class="logo">
<img src="assets/img/GCU_logo.png" alt="Logo" width="90" height="90">
</div>
<div class="logo">
<img id="loading-spinner" style="display: none;" src="assets/img/GCU_LOGO.gif">
</div>
<img id="loading-spinner" src="assets/img/GCU_LOGO.gif">
<h2 style="color:black; font-family: 'Lucida Console', Courier, monospace;">FORGOT PASSWORD</h2>
<h4 style="color:grey; ">Enter your email and we'll send you the verification code to reset your password</h4>
<form id="forgot_pass" method="post">
<label for="email" style="color:black;">Email*</label>
<input type="email" id="email" name="email" required>
<input id="reset"style="background-color:black;color:white;" type="submit" value="Reset Password">
<div class="DJ"> ← <a onclick="bck()" class="D"><b> Back to Log-in</b></a></div>
</form>
</div>
<!-- -->
</body>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
function bck(){
window.history.back();
}
$("#forgot_pass").on("submit", function(event) {
event.preventDefault();
// Show loading spinner
Swal.fire({
title: 'Sending Email',
allowOutsideClick: false,
allowEscapeKey: false,
didOpen: () => {
Swal.showLoading();
},
});
console.log("performing ajax");
$.ajax({
type: 'POST',
url: 'backend/forgot_pass.php',
data: {
email: $("#email").val()
},
success: function(data) {
// Hide loading spinner on success
swal.close();
if (data === "unregistered") {
// alert("This Email in not registered, please use a registered email")
Swal.fire({
icon: "error",
title: "Oops...",
text: "This Email in not registered, please use a registered email",
confirmButtonText: "OK",
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
}
});
console.log(data);
} else {
// alert("The code to change your password is sent to your email")
Swal.fire({
icon: "sucess",
title: "Code Sent!",
text: "Go to your email to retrieve the code",
confirmButtonText: "OK",
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
window.location.href = "verify_code.php";
}
});
console.log(data)
}
// add location to enter code
},
error: function(xhr, status, error) {
// Hide loading spinner on error
swal.close();
console.error("Error:", error);
alert("Error: " + error);
},
});
});
</script>
</html>