title: Password hashing not working in php mysql
body: <p>I am trying to use password hashing using phpmysql. The issue is password_verify does not seem to work for me so far. Say, my password during registration is '123456789'. I stored it in database using</p>
  
  <pre><code>    password_hash('123456789', PASSWORD_BCRYPT, array('cost' =&gt; 12));
  </code></pre>
  
  <p>And then when I enter '123456789' in the login field, it does nothing, fails.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>&lt;?php
          session_start();
          include('db.php');        
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;head&gt;
  
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width,initial-scale=1" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;p/&gt;
  
  &lt;?php
  
      if(isset($_POST['login']) &amp;&amp; $_POST['login'] == 'Login') {
  
          $loginEmail = $_POST['loginEmail'];
          $loginPassword = $_POST['loginPassword'];
  
          $sqlLogin = $db-&gt;prepare("SELECT * FROM registered_users WHERE email = ?");
  
          $sqlLogin-&gt;bind_param("s",$loginEmail);
          $sqlLogin-&gt;execute();
          $sqlLogin = $sqlLogin-&gt;get_result();
          $numrowsLogin = $sqlLogin-&gt;num_rows;
  
          if($numrowsLogin == 1) {
              $rowLogin = $sqlLogin-&gt;fetch_assoc(); 
              $stored_password = $rowLogin['password'];
  
          }
          if(password_verify($loginPassword, $stored_password)){
  
  
             header('Location: homepage.php'); 
          }else{
              echo 'invalid login';
          }      
  
      }         
  ?&gt;
  
  
      &lt;form action = "&lt;?php echo $_SERVER['PHP_SELF'];?&gt;" method="POST"&gt;
          &lt;table style="width:500px"&gt;                        
              &lt;tr&gt;
                  &lt;td width="30%"&gt;&lt;input style="width: 200px; height: 25px; border-radius: 5px;" type="text" name="loginEmail" placeholder = "Email" required/&gt;&lt;br/&gt;&lt;/td&gt;
              &lt;/tr&gt;                    
              &lt;tr&gt;
                  &lt;td width="30%"&gt;&lt;input style="width: 200px; height: 25px; border-radius: 5px;" type="password"  name="loginPassword" placeholder = "Password" required/&gt;&lt;br/&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;input style="font-weight: bold; width: 70px; height: 25px; border-radius: 5px;" type="submit" name="login" value="Login"/&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>