I'm trying to enable my users to login with an email or a username. At the moment only the username is accepted. My working SQL looks like this:
$sql = "SELECT * FROM customers WHERE login = '".$username."' AND password = '".$password."'";
Info:
$usernamehas the value of$_POST['username']$passwordhas the value ofmd5($_POST['password'])
Now I would like to extend it to the email address a customer 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 it doesn't 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?