0

there are two parameters in my app, user will fill one of them, but two parameters will get posted into php,php should select non empty field and do some action! something like this.point me right direction. i think 'isset get' should not be used three times like that right?which statement to be used 'and' or 'or' statement.? i know it's stupid question! i appreciate ur help.

if (isset($_GET['Email']) && !empty($_GET['Fax'])) {
    echo "fax is empty and Email = ".$_GET['Email'];
} elseif (isset($_GET['Fax']) && !empty($_GET['Email'])) {
    echo "email is empty and Fax = ".$_GET['Fax'];
} elseif (!empty($_GET['Fax']) && !empty($_GET['Email'])) {
    echo "Fax and email is empty";
} else {
    echo"empty";
}
3
  • so if i use all of them as empty, how can i use them in remaining program? u mean something like this..if(!empty($_GET['Fax'])){ $fax = $_GET['Fax']} @iStimple Commented Aug 26, 2014 at 18:57
  • thnx @iStimple well, it's for one parameter, how about three parameters, which statement should i use 'or' or 'and'? Commented Aug 26, 2014 at 19:03
  • still confusing,.i will work on it..thnks @iStimple Commented Aug 26, 2014 at 19:10

1 Answer 1

1

Simpler version:

$email = isset($_GET['Email']) ? $_GET['Email'] : null;
$fax   = isset($_GET['Fax'])   ? $_GET['Fax']   : null;

if (empty($email)) {
  // email empty
}
if (empty($fax)) {
  // fax empty
}
Sign up to request clarification or add additional context in comments.

3 Comments

? $_GET['Email'] : null; can u tell me what does it mean? please! @hsZ
@user3923716 It's ternary operator. Manual: php.net//manual/pl/language.operators.comparison.php
if both are empty, both if statements will get executed, how can i do something like if email is only empty(do something), how i can do that? @hsz

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.