Login with user or email in the same field [duplicate]

0

Hello! I have a login code, but I can not get the user to log in with your email or username using the same field! Below is my code, the email on my base date is named "mail".

    
asked by anonymous 19.08.2017 / 04:04

2 answers

0

In order to be able to log in with username and email at the same time, you must add query an OR. Example

SELECT username, password FROM users 
WHERE (username = "usernameRecebido" OR email = "emailRecebido") 
AND password = "passwordRecebido"
    
19.08.2017 / 04:13
0

If I understood your question and your code, you just put a OR :

$userq = mysql_query("SELECT username, password FROM users WHERE (username = '{HoloText($_POST['credentials_username'])}' OR mail='$email') AND password = '$pwd' LIMIT 1");

Tip: Sometimes using javascript to do a field validation gets better and simpler.

    
19.08.2017 / 04:11