Hi Folks:
I was going to propose something similar. Allow me to tweak:
> <form ....>
> *<input type="text" name="my_array[foo]" value="">
> *<input type="text" name="my_array[bar]" value="">
> <input type="text" name="my_array[blankable]" value="">
> </form>
>
> on you script page
> <?
> # $mand = array("foo", "bar");
$mand = array('foo', 'bar');
> # $cnt = count($mand);
> # for ($i = 0; $i < $cnt; $i++)
> # if (!in_array($mand[$i], $my_array))
> # echo "Error: You missed a required field - ".$mand[$i]."<br>\n";
$Prob = array();
while ( list(,$Key) = each($mand) ) {
if ( empty($_POST[$Key]) ) {
$Prob[] = "$Key is a required field";
}
}
if ( !empty($Prob) ) {
echo "<ul>\n";
while ( list(,$Val) = each($Prob) ) {
echo " <li>$Val.</li>\n";
}
echo "</ul>\n";
} else {
# Go ahead. Fields are filled in.
}
> ?>
Enjoy,
--Dan
--
PHP classes that make web design easier
SQL Solution | Layout Solution | Form Solution
sqlsolution.info | layoutsolution.info | formsolution.info
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php