title: password_verify not working when using it in a login form
body: <p>I am learning on implementing login and signup forms using php and have been stuck on password checking with the password_verify() function. The following code fetches for the email address in the table and returns the row which fetches the password(generated via password_hash()) and compares the 2 passwords in the password_verify() function.</p>
  <p>Everytime I get the error password doesn't match(which in my case is an alert box with the text &quot;invalid pass&quot;)</p>
  <p>Any Help will be appreciated!</p>
  <p>{ I may be wrong, It's the first time I'm handling passwords }</p>
  <pre><code>    &lt;?php
  
  require_once &quot;../../conn.php&quot;;
  require_once &quot;../../session.php&quot;;
  $error ='';
  if( isset($_POST['submit'])){
      $email = $_POST['email'];
      $password = $_POST['password'];
      
      if( empty($email)){
      $error= &quot; Please Enter email&quot;;
  
  echo '&lt;script&gt;alert(&quot;PLease enter email&quot;)&lt;/script&gt;'; 
  
      }
      if( empty($password)){
      $error= &quot; Please Enter PAssword&quot;;
  
  
  echo '&lt;script&gt;alert(&quot;PLease enter pass&quot;)&lt;/script&gt;'; 
    
  
      }
      if( empty($error)){
          if($query= $conn-&gt;prepare(&quot;SELECT * FROM users WHERE username =?&quot;)){
              $query-&gt;bind_param(&quot;s&quot;,$email);
              $query-&gt;execute();
              $row=$query-&gt;fetch();
          
              if($row){
              if (password_verify($password,$row['password'])){
                  
                  header(&quot;location:../../index.php&quot;);
                  
              }
              else{
                  $error.= &quot;Password invalid&quot;;
                  
  
  echo '&lt;script&gt;alert(&quot;invalid pass&quot;)&lt;/script&gt;'; 
  
                  
              }
              }
              else{
                  $error.= &quot;No user exists&quot;;
          
  
  echo '&lt;script&gt;alert(&quot;no user&quot;)&lt;/script&gt;'; 
    
  
                  
              }
              
          }
          $query-&gt;close();
      }
      mysqli_close($conn);
  }
  ?&gt;
      
  </code></pre>