title: PHP: PDO if user exists check doesn't work
body: <p>I'm new to PHP, I created User class/object which has a function that checks for user, it returns <code>$stmt-&gt;rowCount()</code> but when I check for it in code it just skip it, register the user..</p>
  
  <p>Here is the code:</p>
  
  <pre><code>if(empty($name_err) &amp;&amp; empty($email_err) &amp;&amp; empty($username_err) &amp;&amp; empty($password_err) &amp;&amp; empty($confirm_password_err)) {   
              if($user-&gt;doesUserExist($email) === 0) {
                      $password = password_hash($password, PASSWORD_DEFAULT);
                      $user-&gt;register($username, $name, $email, $password); 
                  } else {
                      $global_err = "Email is already taken";
                  }
           }
  </code></pre>
  
  <p>Here is the function from User class:</p>
  
  <pre><code>public function doesUserExist($email) {
              $query = "SELECT * FROM users WHERE email = :email";
              $stmt = $this-&gt;connection-&gt;prepare($query);
              $stmt-&gt;bindParam(':email', $email);
              $stmt-&gt;execute();
              $rowcount = $stmt-&gt;rowCount($stmt);
              return $rowcount;
  
          }
  </code></pre>