laziness, impatience, and hubris | |
PerlMonks |
Form Validationby Wally Hartshorn (Hermit) |
on Oct 06, 2003 at 21:57 UTC ( [id://297098]=note: print w/replies, xml ) | Need Help?? |
You indicated that one of the main things he would be doing in PHP is form validation. If that's the case, you might want to take a look at Data::FormValidator. That makes form validation in Perl a snap (to the point where, frankly, it won't take up a significant amount of his time). Here's an example from the program I'm just finishing up:
This is actually part of a CGI::Application-based program, so we're using CGI::Application::ValidateRM instead (which just inherits from Data::FormValidator and calls the appropriate CGI::Application run_mode if necessary). We just list which fields are required, which are optional, which are a "choose at least one of these" group, which must have values that match a certain regex, are required only if some other field has a value, etc. We even verify that the date they've entered is valid. If there's a problem, the form is automagically filled in with the values that they've entered, along with text indicating which fields have problems. When combined with HTML::FillInForm, that leaves very little fiddling that we have to do to process web forms. That allows us to focus on the actually business logic of the program. Anyway, PHP would work fine for doing form validation, but if that's the primary way in which it will be used, you might be better off in the long run just using Perl. It should take just a little time to get something like this going. Wally Hartshorn
In Section
Seekers of Perl Wisdom
|
|