Page 1 of 1

checking multiple variables with an if statement

Posted: Thu Jun 28, 2007 8:43 pm
by malloy
Hi all,

Thanks to all the previous members who have assisted me. I try not to post on here until I have exhausted all other avenues.

Just wondering if there is a way to check if multiple variables are blank.

The example below works for 1 variable but when I specify a second variable 'dob' i get the following error.
Parse error: syntax error, unexpected ',', expecting ')'
which refers to the code below.
I have tried using || to separate the variables too.

Code: Select all

if (empty($_POST['name'], $_POST['dob'])){
echo 'Please fill in all required fields';
}
else {
mail($sendTo, $subject, $headers);
    header("Location: success.php");
}
Any suggestions or links to relevent manual pages would be great.

Kind regards,

malloy

Posted: Thu Jun 28, 2007 8:49 pm
by volka

Code: Select all

if ( empty($_POST['name']) || empty($_POST['dob']) )

Posted: Thu Jun 28, 2007 9:32 pm
by malloy
Thank you very much volka, worked a treat :)