there is a big difference between AND - and OR state. If you want to access both by email and by name, use AND . Also, if you use% variables, use LIKE instead of the = operator, since the latter compares the values ββfor equality, and LIKE compares, matching the values.
$sql=" SELECT * FROM users WHERE fname like '%".$name."%' AND user_email LIKE '%".$email."%'";
The difference between AND and OR is in their value fields.
b1 | b2 | OR | AND **************************** true | true | true | true true | false| true | false false| true | true | false false| false| false| false
(b1 = hit by username, b2 = hit by email), so he selects only the username with OR -statement, because he already has a match.
source share