-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset_password.php
149 lines (130 loc) · 4.51 KB
/
reset_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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recover Your Account</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
nav {
background-color: #333;
padding: 10px 0;
text-align: center;
}
nav a {
color: #fff;
margin: 0 10px;
text-decoration: none;
}
nav a:hover {
text-decoration: underline;
}
.err {
background-color: #FDA403;
font-size: 20px;
padding: 5px;
color: #E8751A;
border-radius: 5px;
margin-top: 2px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.signup-form {
width: 300px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #f9f9f9;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
margin: 8px 0;
box-sizing: border-box;
}
input[type="submit"] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.login-link {
text-align: center;
}
</style>
</head>
<body>
<nav>
<a href="index.php">Home</a>
<a href="notices.php">Notices</a>
<a href="about.php">About</a>
<a href="contact.php">Contact</a>
<?php
if(isset($_SESSION['login']) && $_SESSION['login'] === true) {
echo '<a href="logout.php">Logout</a>';
} else {
echo '<a href="login.php">Login</a>';
}
?>
<a href="signup.php">Sign up</a>
</nav>
<div class="container">
<div class="signup-form">
<h2>Recover Your Account</h2>
<form id="recoverForm">
<label for="username">Email ID</label>
<input type="text" id="username" name="username" placeholder="Your Email ID.." required>
<input type="submit" value="Send Mail" name="forgot">
</form>
<div class="login-link">
<p>Already have an account? <a href="login.php">Login here</a></p>
</div>
<div style="color: red; padding-left:15px" id="responseMessage" class="response-message"></div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var recoverForm = document.getElementById('recoverForm');
var responseMessage = document.getElementById('responseMessage');
recoverForm.addEventListener('submit', function(event) {
event.preventDefault();
var username = document.getElementById('username').value;
// AJAX request to send form data to the server
var xhr = new XMLHttpRequest();
xhr.open('POST', 'forgotpass.php'); // Replace 'forgotpass.php' with your server-side script URL
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
var response = xhr.responseText;
responseMessage.innerHTML = response;
setTimeout(function() {
responseMessage.innerHTML = ''; // Clear the response message after 5 seconds
window.location.href="otppage.php";
}, 5000);
} else {
responseMessage.innerHTML = 'Request failed. Please try again later.';
}
};
var formData = 'username=' + encodeURIComponent(username);
xhr.send(formData);
});
});
</script>
</body>
</html>