title: Using password_hash with bindParam
body: <p>I'm trying to create a login system using Slim Jquery and Ajax. I've got the log in part working with minimal issues, now I just need to be able to hash the password. I know I can use md5, sha1 and/or salt to hash but I know that it is recommenced that password_hash is used instead. I know how to hash with any of the other 3 I mentioned because while using bindParam you can just place it around the variable. My question is, how do I use password_hash with bindParam. The closest answer I found on this site didn't do much to help.</p>
  
  <p>My current code is:</p>
  
  <pre><code>$app-&gt;post('/addUser/', 'addUser');
  function addUser()
  {
      $request = \Slim\Slim::getInstance()-&gt;request();
      $q = json_decode($request-&gt;getBody());
  
      $sql = "INSERT INTO users(firstName, lastName, userName, password) VALUES (:firstName, :lastName, :userName, :password)";
  
      try{
          $dbConnection();
          $stmt=$db-&gt;prepare($sql);
          $stmt-&gt;bindParam("firstName", $q-&gt;firstName);
          $stmt-&gt;bindParam("lastName", $q-&gt;lastName);
          $stmt-&gt;bindParam("userName", $q-&gt;userName);
          $stmt-&gt;bindParam("password", $q-&gt;password);
          $stmt-&gt;execute();
          $db=null;
      }
      catch(PDOException $e){
          echo $e-&gt;getMessage();
      }
  }
  </code></pre>
  
  <p>Verify Code:</p>
  
  <pre><code>$app-&gt;post('/logIn/', 'lonIn');
  function logIn()
  {
      $request = \Slim\Slim::getInstance()-&gt;request();
      $q = json_decode($request-&gt;getBody());
  
      $sql = "SELECT * FROM users WHERE userName=:userName";
      try{
          $db = getConnection();
          $stmt=$db-&gt;prepare($sql);
          $stmt-&gt;bindParam("userName", $q-&gt;userName);
          $execute = $stmt-&gt;execute();
          $db = null;
      }
      catch(PDOException $e)
      {
          echo $e-&gt;getMessage();
      }
      if($execute == true)
      {
          $array = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
          $hashedPassword = $array['password'];
          if(password_verify($q-&gt;password), $hashedPassword))
          {
              echo 'Valid';
          }
          else
          {
              echo 'Invalid';
          }
      }
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>