Have some data posted to me :
test.com?firstname='John'&surname='Wick'&email='jwick@test.com'
What I want to do is check the above data with what I have in my DB, and if any of the data is the same then echo out a response and if its not the same then echo out a different response. It needs to check all 3 fields, even if 2 Don't match and one does.
Lets assume the value's from my DB request are:
$Email = 'jwick@test.com';
$FirstName = 'John';
$Surname = 'Wick';
This is what I have tried :
if(
$Email == $_GET['email'] &&
$FirstName == $_GET['firstname'] &&
$Surname == $_GET['surname']
){}
What happens is it only compares the $Email
and ignores the rest, what is the best way to do this. Basically what i am trying to do is that is create a simple dedupe
Instead of AND (&&) clause use the OR (||) clause:
if( $Email == $_GET['email'] ||
$FirstName == $_GET['firstname'] ||
$Surname == $_GET['surname']
){ //do somthing}
It will check if any one condition is true and matched with the posted data then it will execute the if condition.
AND(&&) condition always check all the condition should be true and matched.
OR(||) condition is used to check any of the given condition should be true. It may one condition or more than one condition can be fullfill.