I don't know what this is as still a beginner: var_dump($numrows);
var_dump() returns information about expressions TRUE < FALSE
or variables. For example:
$stmt = TRUE === TRUE || TRUE < FALSE && TRUE === FALSE;
$str = 'Hello';
$fp = fopen('php://memory', 'w+');
var_dump($stmt, $str, $fp);
It will return the data type and the value:
bool(true)
string(5) "Hello"
resource(3) of type (stream)
In my previous comment, I suggested you to verify the contents of the $numrows variable, to make sure you were receiving an integer (as expected) or NULL, which would suggest an error with the query.
About the code, I understand what you want to achieve, however query to verify only if the username or the email address exists, exclude the password for now, so do:
SELECT * FROM users WHERE usernames='abc' OR emails='abc' LIMIT 1;
I'm adding LIMIT 1
here, which can be avoided if you set unique keys on usernames and emails columns.
Once you get the row, fetch the password from the result set and compare it with the one submitted in the login request.
Right now, I suppose you are saving passwords in plain text, you should use password_hash()
to generate the hash to save into the database and password_verify()
to verify the attemp with the hash.
Read the following tutorial by Diafol, #11 Storing and Retrieving Authentication Data, which shows exactly the same approach that I would use here:
It is developed for PDO and uses prepared statements, …