Then it uses $error_count to see if the page should be displayed.
If that is the case, then you are not interested in how many errors there were, only in whether or not there was at least one error. Realistically, you are not going to check for blank fields alone - even if the fields are filled you would validate them, and invalid but filled fields are still errors.
Consider a form that takes in a name and an age. You might be willing to let the user enter numbers in addition to letters and spaces for the name, or even exclamation marks (think Kalahari desert people), so there you might only check that the field is not empty. But surely the age will be filled with a non-negative integer (you dont expect people to calculate their age to the second and express in years, after all).
A possible error checking snippet might be:
//check for form data entry errors
$errors = array();
//form should be submitted via POST method
if (empty($_POST['name'])) {
$errors[] = 'Name not specified';
}
if (empty($_POST['age']) || !ctype_digit($_POST['age']) || $_$POST['age'] < 0) {
$errors[] = 'Age not specified, or invalid';
}
//are there any form data entry errors?
if (($error_count = count($errors)) == 0) {
//process the form
} else {
//print the form data entry errors
echo "Error:<br />\n";
for ($i = 0; $i < $error_count; $i++) {
echo $error[$i] . "<br />\n";
}
}