112 lines
4.5 KiB
PHP
112 lines
4.5 KiB
PHP
<?php define('HEADER_VARIANT', '02');
|
|
require_once('header.php');
|
|
$token = $_GET['token'] ?? '';
|
|
|
|
if (empty($token)) {
|
|
die("Invalid token.");
|
|
}
|
|
|
|
// Verify the token
|
|
$sql = "SELECT user_id FROM password_resets WHERE token = ? AND expires_at > NOW()";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("s", $token);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
if ($result->num_rows === 0) {
|
|
die("Token is invalid or expired.");
|
|
}
|
|
|
|
$user = $result->fetch_assoc();
|
|
$user_id = $user['user_id'];
|
|
|
|
// Display the reset password form
|
|
?>
|
|
|
|
<style>
|
|
@media (min-width: 991px) {
|
|
.container {
|
|
max-width: 720px;
|
|
padding: 0 15px; /* Ensure padding doesn't cause overflow */
|
|
}
|
|
</style>
|
|
<!-- Contact Form Area start -->
|
|
<section class="contact-form-area py-120 rel z-1">
|
|
<div class="container">
|
|
<div class="row align-items-center">
|
|
|
|
|
|
<div class="">
|
|
<div class="comment-form bgc-lighter z-1 rel mb-30 rmb-55">
|
|
<form id="changePasswordForm" class="loginForm" name="changePasswordForm" action="update_password.php" method="post" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">
|
|
<div class="section-title">
|
|
<h2>Reset Password</h2>
|
|
<div class="pt-20" style="text-align: center;" id="responseMessage"></div> <!-- Message display area -->
|
|
</div>
|
|
<div class="row mt-35">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<label for="new_password">New Password</label>
|
|
<input type="password" id="new_password" name="new_password" class="form-control" placeholder="Enter password" value="" required data-error="Please enter your password">
|
|
<div class="help-block with-errors"></div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<label for="confirm_password">Confirm Password</label>
|
|
<input type="password" id="confirm_password" name="confirm_password" class="form-control" placeholder="Confirm password" value="" required data-error="Please confirm your password">
|
|
<div class="help-block with-errors"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
<div class="form-group mb-0">
|
|
<input type="hidden" name="token" value="<?php echo htmlspecialchars($token); ?>">
|
|
<button type="submit" class="theme-btn style-two" style="width:100%;">Reset Password</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- Contact Form Area end -->
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Change Password
|
|
$('#changePasswordForm').on('submit', function(event) {
|
|
event.preventDefault(); // Prevent default form submission
|
|
|
|
$.ajax({
|
|
url: 'update_password.php',
|
|
type: 'POST',
|
|
data: $(this).serialize(),
|
|
success: function(response) {
|
|
// Parse response if needed
|
|
if (typeof response === "string") {
|
|
response = JSON.parse(response);
|
|
}
|
|
|
|
if (response.status === 'success') {
|
|
$('#responseMessage').html('<div class="alert alert-success">' + response.message + '</div>');
|
|
} else {
|
|
$('#responseMessage').html('<div class="alert alert-danger">' + response.message + '</div>');
|
|
}
|
|
},
|
|
error: function() {
|
|
$('#responseMessage2').html('<div class="alert alert-danger">Error changing password.</div>');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php include_once("insta_footer.php"); ?>
|