1

How can I check if email = '$e' or username = '$e' inside my MySQL query.

Here is my MySQL query so far.

"SELECT user_id FROM users WHERE (email = '$e' AND pass=SHA1('$p'))"        

1 Answer 1

2

If you want to modify you existing query so that it works even if $e matches username, you can do:

SELECT user_id 
FROM users 
WHERE (email = '$e' OR username = '$e') AND pass=SHA1('$p')
Sign up to request clarification or add additional context in comments.

1 Comment

I'd probably look at $e in your program, though, and decide if I want to treat it as either email or username.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.