Re: Error Checking
| From: | O. | Date: | Fri, 21 Jul 2000 16:07:49 +0000 |
| Subject: | Re: Error Checking | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7595@lists.php.net to get a copy of this message | ||
""Jeff Wilhelm"" <jeffwilhelm@hotmail.com> wrote in message
news:OE35L7d2V5k4q9mb9cQ000014f9@hotmail.com...
> How would I check a bunch of variables for errors and display an error
> message if they have errors or continue on into the script if they are
> correct?
> In psuedo code I want to do the following, but am unsure how to code it:
> (note: not all the variables have the same validity checks, so I can't
just
> loop through them... for example one might be an e-mail address, and the
> other a phone number)
If they aren't the same, create some function which can validate all the
types you expect to receive.
validate_data($datavar, $datatype)
where $datatype can indicate to the function what check to use.
Then you can use a loop provided these variables are in some array.
$flag = validate_data(...)
You could even get fancy and update $flag with different values, or append
values to $flag to indicate how many fields had errors and what kinds ...
I'm getting excited just thinking about the possibilities ...
I personally just validate each inline ... a bit inelegant, but it's faster
to write and it works ;) .
--
O.