  <?php 
  
  if (isset($_REQUEST['change_password'])) {
            $cp = $_POST['cp'];
            $np = $_POST['np'];
            $cnp = $_POST['cnp'];
            $user = $_POST['user'];
    
            // Verify Current Password
            include 'lib/dbcon.php';
            include 'lib/main.php';
            $db = new Main;
            $Verify = "SELECT * FROM `admin` WHERE id = '".$user."'";
            $Verify_run = mysqli_query($con,$Verify);
            $row = mysqli_fetch_array($Verify_run);
            if(password_verify($cp, $row['password'])) {
                //echo "Matched";
                if ($np!= $cnp) {

                    $_SESSION['msg_err'] = 'New Password And Confirm Password Did Not Matched!';
                    
                    header('location:change_password.php');
                }
                else {
                    $pass = password_hash($np, PASSWORD_BCRYPT);
                    $update_pass = "UPDATE `admin` SET password = '".$pass."' WHERE id = '".$user."'";
                    if ($db->update($update_pass)) {
                        $db->update("UPDATE `admin-login` SET password = '$pass' WHERE id = '$user'");
                        $_SESSION['msg_scs'] = 'Your password has been changed successfully';
                        header('location: change_password.php');
                    }
                    else {
                        echo "Something Went Wrong Try Again Later!";
                        header('location: change_password.php');
                    }
    
                }
    
            }
            else{
                //echo 'Current Password Not Matched';
                $_SESSION['err'] = "Current Password Not Matched";
                header('location:change_password.php');
            }
    
        }// end individual_change_password
        
        ?>