Entry
Is there a quick way to check that all form fields were entered?
Jan 23rd, 2000 20:03
Nathan Wallace, Richard Lynch
Try something like this that just checks to see that all the POST
variables are not empty.
<?php
if (isset($HTTP_POST_VARS)){
while(list($var, $val) = each($HTTP_POST_VARS)){
if (empty($val)){
$bad[$var] = 1;
} } }
?>
<FORM ...>
<?php
if (isset($bad)){
echo "<FONT COLOR=FF0000>All Fields Required</FONT>";
}
?>
<?php if (isset($bad['whatever'])){
echo "<FONT COLOR=FF0000>";
?>
Whatever: <INPUT NAME=whatever>
</FORM>