Return to Snippet

Revision: 47803
at June 16, 2011 14:21 by chopbust


Initial Code
//---- validation ------ //	
$count = 0;
$required_fields = array('name', 'id_no');
$required_fields_description = array('Name of the user', 'Id');
	
//check all required forms
foreach($required_fields as $fields) {
   if ($_POST[$fields] == "") $error_check .= "You need to enter field '".$required_fields_description[$count]."'. Go back. <br />";
   $count++;
}
	
if ($error_check != "") die($error_check);
//----- end validation ------//

Initial URL

                                

Initial Description
A generic loop-based form validation to check which _POST value is empty. 

Enter the form name in Line 3 and put the description in Line 4.

Initial Title
Server Side Form Validation

Initial Tags

                                

Initial Language
PHP