It is a straightforward task.
What you want to do is make sure that none of the form fields are empty.
That means you either check for each field manually;
if ($field=='')
{
echo 'field empty';
};
etc etc.
Or you create a loop that checks all the vars you can find:
while(list($key,$val) = each($HTTP_GET_VARS))
{
if ($val=='')
{
echo $key.' empty';
};
};
To get the result of 'fields empty' or 'no fields empty' you only have to set the var to 'fields empty' or not:
$fields_empty = 'no';
while(list($key,$val) = each($HTTP_GET_VARS))
{
if ($val=='')
{
echo $key.' empty';
$fields_empty = 'yes';
};
};
echo $fields_empty;
Now, if no fields are empty, the fields_empty var is never changed, so it says 'no'. If a field is empty, the IF statement will match and set the fields_empty var to 'yes'.
Notice that the var is NOT reset to 'no' inside the loop.
Big thing to note here is that you start the checks with 'everything is ok'
then while you check you change that to 'fields missing' if there are any missing.
If a field is not empty, then that is no cause for alarm, and you should NOT reset the status to 'no fields missing'