-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforgot_password.php
57 lines (52 loc) · 1.9 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
<?php
$pageTitle = "Forgot Password - PureComfort Luxury Accommodations";
$pageDescription = "Reset your password for PureComfort.";
include 'includes/header.php';
?>
<!-- Hero Section -->
<header class="hero forgot-password-hero">
<div class="container">
<h1 class="fade-in">Forgot Your Password?</h1>
<p class="lead text-white fade-in">Enter your email to reset your password</p>
</div>
</header>
<!-- Reset Password Section -->
<section class="reset-password-section py-5">
<div class="container">
<form id="resetPasswordForm">
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<button type="submit" class="btn btn-primary">Send Reset Link</button>
</form>
<div id="resetMessage" class="mt-3"></div>
</div>
</section>
<?php include 'includes/footer.php'; ?>
<script>
document.getElementById('resetPasswordForm').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email').value;
fetch('backend/process_reset_password.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ email: email })
})
.then(response => response.json())
.then(data => {
const messageDiv = document.getElementById('resetMessage');
if (data.success) {
messageDiv.innerHTML = '<p class="text-success">' + data.message + '</p>';
} else {
messageDiv.innerHTML = '<p class="text-danger">' + data.message + '</p>';
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('resetMessage').innerHTML = '<p class="text-danger">An error occurred. Please try again.</p>';
});
});
</script>