I am trying to allow my users to log in by email or by username. Currently, only the username is accepted. My working SQL looks like this:
$sql = "SELECT * FROM customers WHERE login = '".$username."' AND password = '".$password."'";
information:
$username is $_POST['username']$password is md5($_POST['password'])
Now I would like to distribute it to an email address that a client can enter in his profile. My SQL looks like this:
$sql = "SELECT * FROM customers WHERE (login = '".$username."' OR email = '".$username."') AND password = '".$password."'";
I will check this SQL with:
$result = mysql_query($sql); mysql_num_rows($result)
But at the moment this does not work. If I use OR in my SQL, mysql_num_rows returns 0 . What could be the problem? Or is there another and better way to achieve this?
source share