No offense to Halfabee but what was posted is broken.
Use it the way I indicated.
$required_fields = array('name', 'email', 'address1');
function isformfilled($formdata, $required_fields) {
$result = TRUE;
foreach ($formdata as $key => $value) {
if (in_array($key, $required_fields) && ($value == '')) {
echo "You did not enter a value for {$key}.<br>\n";
$result = FALSE;
}
}
if ($result == FALSE) {
return FALSE;
}
}
if (isformfilled($_POST, $required_fields) == FALSE) {
// Do some action since the form was not filled.
}
You'll notice that I am passing $_POST which is the entire $HTTP_POST_VARS array, which contains all the values that came in from the form. The foreach() function walks through the $POST array.