I have created the below code to update the password in user form. But when I try to update the password with incorrect details, the DB is not updating but returing the success message
<?php
if (isset($_POST['create']))
{
$m_number = $_POST['user_mobile_number'];
$u_nic = $_POST['user_nic'];
$u_lname = $_POST['user_login_name'];
$u_password = $_POST['user_password'];
$sql = "UPDATE `user` SET `user_password` = '$u_password' WHERE `user_login_name` = '$u_lname' && `user_mobile_number` = '$m_number' && `user_nic` = '$u_nic'";
if (mysqli_query($db, $sql))
{
if ($sql)
{
?>
<script type="text/javascript">
Swal.fire(
'WooHoo!',
'Your password change successfully!',
'success'
).then((result) => {
if (result.value) {
window.location="login.php";
}
})
</script>
<?php
}
else
{
echo "Error";
}
}
else
{
}
}