[thelist] field checking in PHP

noah noah at tookish.net
Mon Dec 17 21:57:07 CST 2001


I'm using PHP to write a form that puts data into a MySQL database. This 
one form is part of a larger registration process.

In this case, none of the fields are required (i.e., the user doesn't need 
to fill anything out), but if one field is filled out, they all have to be.

In a two field form, in order to make sure that the fields are filled out 
properly, I've done this:

if (($level && !$major) || ($major && !$level)) {
   *return an error*
}

The problem is that I need to do the same thing with a 13 field form; as 
you can probably imagine, using the approach above will get unwieldy in a 
big, big hurry. Does any one know of a better way of checking to make sure 
that if one field is filled out, they all are?

Thanks,
Noah





More information about the thelist mailing list