%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/public_html/website_93b53270/ |
Upload File : |
<?php include('header.php');
if(!isset($_SESSION['user_id'])){
echo "<script>window.location='login.php'</script>";
}
?>
<section id="chng-pwd">
<div class="container">
<div class="row">
<div class="col-md-4">
<?php include('user-sidebar.php'); ?>
</div>
<div class="col-md-8">
<div class="bg-white p-5 br-20 my-5 box-shadow">
<?php if(isset($_SESSION['message'])): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark"><?php echo $_SESSION['message']; ?> <i class="feather icon-thumbs-up text-danger"></i></strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['message']); ?>
<?php endif; ?>
<?php if(isset($_SESSION['error'])): ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong class="text-danger"><?php echo $_SESSION['error']; ?> <i class="feather icon-thumbs-up text-dark"></i></strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
<form action="" method="POST">
<div class="row">
<div class="col-md-12">
<input id="old_password-field" type="password" placeholder="Old Password" name="old_password" class="form-control mb-3">
<span toggle="#old_password-field" class="ri-eye-off-line eye-icon" id="oldtogglePassword"></span>
</div>
<div class="col-md-12">
<input id="new_password-field" type="password" placeholder="New Password" name="password" class="form-control mb-3">
<span toggle="#new_password-field" class="ri-eye-off-line eye-icon" id="newtogglePassword"></span>
</div>
<div class="col-md-12">
<input id="new_conf_password-field" type="password" placeholder="Confirm Password" name="cpassword" class="form-control mb-3">
<span toggle="#new_conf_password-field" class="ri-eye-off-line eye-icon" id="newconftogglePassword"></span>
</div>
<div class="col-md-12">
<button type="submit" name="change_password" class="btn-theme w-100 nextBtn">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?php include('footer.php'); ?>
<script type="text/javascript">
$("#oldtogglePassword, #newtogglePassword, #newconftogglePassword").click(function() {
$(this).toggleClass("ri-eye-off-line ri-eye-line");
var input = $($(this).attr("toggle"));
if (input.attr("type") == "password") {
input.attr("type", "text");
} else {
input.attr("type", "password");
}
});
</script>
<?php
if(isset($_POST['change_password'])){
$old_password = mysqli_real_escape_string($conn, $_POST['old_password']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$cpassword = mysqli_real_escape_string($conn, $_POST['cpassword']);
// Password match validation
if ($password != $cpassword) {
$_SESSION['error'] = "Passwords don't match! Try again.";
echo "<script>window.location='change-password.php';</script>";
exit;
}else{
$loginQry = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE password='$old_password' AND user_id = '".$_SESSION['user_id']."'");
if(mysqli_num_rows($loginQry) > 0){
mysqli_query($conn,"UPDATE `user_tbl` SET `password`='$cpassword' WHERE user_id = '".$_SESSION['user_id']."'");
echo "<script>window.location='change-password.php';</script>";
$_SESSION['message'] = "Successfully change password!.";
} else {
echo "<script>window.location='change-password.php'</script>";
$_SESSION['error'] = 'Your old password does not match.';
}
}
}
?>