Avis
Avis

Reputation: 505

Php how to use multiple parameters

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";
}

Upvotes: 0

Views: 54

Answers (1)

hsz
hsz

Reputation: 152216

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
}

Upvotes: 1

Related Questions