Hi guys I am implementing a password validation in my project.
Validate Current password in order to change a new password..
here is my query:
$res=mysql_query("SELECT * FROM users WHERE id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
$pass = $userRow['password'];
    if(isset($_POST['update'])){
        $id = $_SESSION['user'];
        $new_pass = md5(mysql_real_escape_string($_POST['new_pass']));
        if($_POST['old_pass'] != $pass){
            ?>
                <script>alert('Wrong Old Password');</script>
             <?php
        }else if(mysql_query("UPDATE users SET password='$new_pass' WHERE id=$id")){
             ?>
                <script>alert('Password Successfully Updated');</script>
             <?php
         }else{
             ?>
               <script>alert('Failed');</script>
             <?php
         }
    }
the alert "Wrong Old Password" always popping out even though I entered the correct old password. so how to fix this?
 
     
     
    