|
How to make a user change password PHP script work
Changing User Password in PHP and mySQL php - Allow user to change password
Changing User Password in PHP and mySQL php - Allow user to change password
<?php
$c = $_SESSION['customer_email'];
if(isset($_POST['change_pass'])){
$old_pass = $_POST['old_pass'];
$new_pass = $_POST['new_pass'];
$new_pass_again = $_POST['new_pass_again'];
$get_real_pass = "select * from customers where customer_pass='$old_pass' AND customer_email='$c'";
$run_pass = mysqli_query($con, $get_real_pass);
if(mysqli_num_rows($run_pass)==0){
echo "<script>alert('Your Current Password is Wrong.')</script>";
exit();
}
if($new_pass != $new_pass_again){
echo "<script>alert('Your New Password is not match with new password again.')</script>";
exit();
}else{
$update_pass = "update customers set customer_pass='$new_pass' where customer_email='$c'";
$run_update = mysqli_query($con, $update_pass);
echo "<script>alert('Your password has been successfully updated!')</script>";
echo "<script>window.open('my_account.php','_self')</script>";
}
}
?>
Categories: PHP Tricks
Leave a comment