I have tried only with count($result) > 0 but it doesn't work, with strlen and neither and this example doesn't work for me either, how can I check if the account exists?
$result = mysqli_query($base,"SELECT * FROM $users WHERE email = '$email' AND password = '$password'");
if (count(mysql_fetch_array($result)) > 1) {
echo "Login...";
}
You can do something like this:
I hope I can help you ;)
The problem in your code is that you are using the old function
mysql_fetch_array
(without thei
), which would be deprecated .On the other hand, the safest and most effective way to know if there are records is by counting .
Also, to prevent risk of SQL Injection , consider using prepared queries .
This is how it should work:
For more details on prepared queries in mysqli see the PHP Manual and to understand the enormous risk we are preventing by implementing this code, read about the SQL Injection topic .