title: How to change password using password_hash?
body: <p>I've tried changing this php code into a password_hash when the user input his password if he wants to change it, but it will never match because the pssword stored in my database is hashed during register, so i need the old pw which he input to match with the hashed password on db which is not working. </p>
  
  <p>I know I should use password_verify butI do not know which part of this code should I insert it? </p>
  
  <pre><code>&lt;?php
    include 'session.php';
    $db = new mysqli('localhost', 'root', '', 'alumni');
    if(isset($_POST['submit'])):
    extract($_POST);
  
  
    $user_check=$_SESSION['login_user'];
  
    $old_pwd=$_POST['old_password'];
    $pwd=$_POST['password'];
    $c_pwd=$_POST['confirm_pwd'];
    if($old_pwd!="" &amp;&amp; $pwd!="" &amp;&amp; $c_pwd!="") :
  
  
    if($pwd == $c_pwd) :
    if($pwd!=$old_pwd) :
      $sql="SELECT * FROM `alumni` WHERE `username`='$user_check' AND `password` ='$old_pwd'";
      $db_check=$db-&gt;query($sql);
      $count=mysqli_num_rows($db_check);
    if($count==1) :
      $fetch=$db-&gt;query("UPDATE `alumni` SET `password` = '$pwd' WHERE `username`='$user_check'");
      $old_pwd=''; $pwd =''; $c_pwd = '';
      $msg_sucess = "Password successfully updated!";
    else:
      $error = "Old password is incorrect. Please try again.";
    endif;
    else :
      $error = "Old password and new password are the same. Please try again.";
    endif;
    else:
      $error = "New password and confirm password do not match.";
    endif;
    else :
      $error = "Please fill all the fields";
    endif;   
    endif;
  ?&gt; 
  </code></pre>