Reputation: 21
I have been racking my brain for a bit and getting nowhere. I'm probably missing something really simple, but what I effectively need is.
if string 1 or 2 is set then compare with string 3 providing string 3 is not null.
if($_SESSION['code'] || $_GET['id'] <> $_POST['code'] && isset($_POST['code']))
Upvotes: 0
Views: 305
Reputation: 3187
This could be
if(!empty($_SESSION['code']) && !empty($_GET['id']) && !empty($_POST['code'])
($_SESSION['code'] == $_POST['code'] || $_GET['id'] == $_POST['code']))
This means all the variables must be set and have value then it compares if the $_SESSION['code'] or $_GET['id'] is equal with the $_POST['code']
Upvotes: 0
Reputation: 2970
if((!empty($_POST['code']) || !empty($_SESSION['code'])) && $_GET['id']<>$_POST['code']){
Upvotes: 0
Reputation: 3256
I'm not sure I follow, but you're logic seems to state:
if(isset($string3)){
if(isset($string1)){
strcmp($string1,$string3);
}elseif(isset($string2)){
strcmp($string2,$string3);
}
}
Upvotes: 1
Reputation: 324640
if( ($a = $_SESSION['code'] ? $_SESSION['code'] : $_GET['id'])
&& isset($_POST['code']) && $a == $_POST['code']) {
If you want $_GET['id']
to override $_SESSION['code']
in the case that both are set:
if( ($a = $_GET['id'] ? $_GET['id'] : $_SESSION['code'])
&& isset($_POST['code']) && $a == $_POST['code']) {
More correctly:
if( (isset($_SESSION['code']) || isset($_GET['id']))
&& ($a = isset($_GET['id']) ? $_GET['id'] : $_SESSION['code'])
&& isset($_POST['code']) && $a == $_POST['code']) {
Upvotes: 0
Reputation: 18833
if(isset($string3) && ((isset($string1) && $string1 == $string3) || (isset($string2) && $string2 == $string3)))
Something like this would work. First see if isset $string3. Then a wrapped or operator individually checking isset $string1 or 2 and if they equal string 3.
Upvotes: 0