News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer's Blog:
Validating POST fields the easy way
December 15, 2008 @ 16:44:17

Sameer has posted his "easy way" to validate user input coming in over a POST request:

Validating POST data from a form is a common requirement for a developer. If the number of form fields are few than the validation is a small matter. But the case is different when the form contains more than 15 or 20 fields and some of the fields are mandatory. The following code will give you an idea of how to easily validate mandatory fields, whatever the number of fields.

His method prefixes the form fields with a certain string (in his case "c_") and uses that to loop through and act as a hook to check only the form values that were submitted (and nothing else that happens to be in the $_POST array). Any number of checks could be added on to this simple example including type checks, length and validating off of another field - like a password confirm match.

0 comments voice your opinion now!
validate form value easy tutorial


blog comments powered by Disqus

Similar Posts

Robert Basic's Blog: Debugging two PHP projects in Netbeans at the same time

Chance Garcia's Blog: MAMP PRO, PECL, SSH2, and OSX CLI (AKA acronym madness)

Profeshunl Newbie Blog: MongoDB as in huMONGOus, not retarded

WorkingSoftware.com.au: Something Like Threading- PHP Process Forking & Interprocess Communication

DevShed: Creating an Administration Area for a Simple Threaded Discussion Forum


Community Events





Don't see your event here?
Let us know!


community podcast version mvc security symfony voicesoftheelephpant interview library tool package language laravel release introduction series composer opinion update framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework