title: Warning: Trying to access array offset on value of type bool
body: <p>Login form working fine, but when I enter the wrong username getting an error this</p>
  <blockquote>
  <p>Warning: Trying to access array offset on value of type bool</p>
  </blockquote>
  <p>I have a login form with this code:</p>
  <pre><code>&lt;?php
  include('class.password.php');
  
  class User extends Password{
  
      private $db;
  
      function __construct($db){
          parent::__construct();
  
          $this-&gt;_db = $db;
      }
  
      public function is_logged_in(){
          if(isset($_SESSION['loggedin']) &amp;&amp; $_SESSION['loggedin'] == true){
              return true;
          }
      }
  
      private function get_user_hash($username){
  
          try {
  
              $stmt = $this-&gt;_db-&gt;prepare('SELECT MemberID, username, password FROM admins WHERE username = :username');
              $stmt-&gt;execute(array('username' =&gt; $username));
  
              return $stmt-&gt;fetch();
  
          } catch(PDOException $e) {
              echo '&lt;p class=&quot;error&quot;&gt;'.$e-&gt;getMessage().'&lt;/p&gt;';
          }
      }
  
  
      public function login($username,$password){
  
          $user = $this-&gt;get_user_hash($username);
  
          if($this-&gt;password_verify($password,$user['password']) == 1){
  
              $_SESSION['loggedin'] = true;
              $_SESSION['memberID'] = $user['memberID'];
              $_SESSION['username'] = $user['username'];
              return true;
          }
      }
  
  
      public function logout(){
          session_destroy();
      }
  
  }
  
  
  ?&gt;
  </code></pre>
  <p>This is what's on the line that gives the error:</p>
  <pre><code>if($this-&gt;password_verify($password,$user['password']) == 1){
  </code></pre>