Hi po, pa help naman po ako dito sa codes ko . kapag hindi sya same ng password na nilagay hindi po lumalabas yung script alert na "Password don't match" . Thanks in advance
<h2 style="text-align:center;">Change your password</h2>
<form action="" method="post">
<table align="center" width="700">
<tr>
<td align="right"> <b> Current Password: </b> </td>
<td> <input type="password" name="current_pass" required /> </td>
</tr>
<tr>
<td align="right"> <b> New Password: </b> </td>
<td> <input type="password" name="new_pass" required /> </td>
</tr>
<tr>
<td align="right"> <b> Confirm New Password: </b> </td>
<td> <input type="password" name="new_pass_again" required /> </td>
</tr>
<tr align="center">
<td colspan="8"> <input type="submit" name="change_pass" value="Change Password" /> </td>
</tr>
</table>
</form>
<?php
include("includes/db.php");
if(isset($_POST['change_pass'])) {
$user = $_SESSION['cust_email'];
$current_pass = $_POST['current_pass'];
$new_pass = $_POST['new_pass'];
$new_again = $_POST['new_pass_again'];
$sel_pass = "SELECT * FROM customers WHERE cust_pass='$current_pass' AND cust_email='$user'";
$run_pass = mysqli_query($con, $sel_pass);
$check_pass = mysqli_num_rows($run_pass);
if($check_pass==0) {
echo "<script>alert('Your current password is wrong!')</script>";
exit();
}
if($new_again!=$new_pass) {
echo "<script>alert('Password don't match!')</script>";
}
else {
$update_pass = "UPDATE customers SET cust_pass='$new_pass' WHERE cust_email='$user'";
$run_update = mysqli_query($con, $update_pass);
echo "<script>alert('Password Changed Succesful!')</script>";
echo "<script>window.open('my_account.php','_self') </script>";
}
}
?>