<?php
/*
Almost for every submitted form you need a simple form check about the required fields. The validation and reporting will become very hard to handle if you have more then three required fields. This function will do all this work: Validation of required fields and the error reporting. After submitting you get a message which fields are empty and the empty fields are in a different colour. The example will handle only the text type input elements.
*/
// use associative array's if you like
$req_fields = array("name", "timestamp"=>"Your time", "field");
$msg = "The following (required) fields are empty:";
<?php
if (isset($_POST)) check_empty_fields();
// and the form field like:
// echo <input type=\"text" name=\"name\"";
// if (isset($_POST['name'])) echo " value=\"".$_POST['name']."\"";
// if (!$GLOBALS['name']) echo " class=\"invalid\">";
?>