title: Login with username or email
body: <p>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:</p>
  
  <pre><code>$sql = "SELECT * FROM customers WHERE login = '".$username."' AND password = '".$password."'";
  </code></pre>
  
  <p>Info:</p>
  
  <ul>
  <li><code>$username</code> has the value of <code>$_POST['username']</code></li>
  <li><code>$password</code> has the value of <code>md5($_POST['password'])</code></li>
  </ul>
  
  <p>Now I would like to extend it to the email address a customer can enter in his profile. My SQL looks like this:</p>
  
  <pre><code>$sql = "SELECT * FROM customers WHERE (login = '".$username."' OR email = '".$username."') AND password = '".$password."'";
  </code></pre>
  
  <p>I will check this SQL with:</p>
  
  <pre><code>$result = mysql_query($sql);    
  mysql_num_rows($result)
  </code></pre>
  
  <p>But at the moment it doesn't work. If I use <code>OR</code> in my SQL, <code>mysql_num_rows</code> returns <code>0</code>. What could be the problem? Or is there another and better way to achieve this?</p>