It is absolutely essential that you validate data submitted through forms on your web site. Forms are the wild-wild-west. Without forms validation, it is not a question of if you will be hacked, it is a question of when.
I have been using FormValidator for years, updating it regularly with new exploits as they become known. FormValidator has some unique rules, and some that are absolute must-have. Check out the Rules section for an overview.
We are also including language files with FormValidator. The first three are english, french, and spanish. If you would like to contribute others, please send them to me and I will include them as downloadable here and in future releases.
Here is basic usage:
<?php
if(isset($_POST['Submit'])) {
require_once "FormValidator.php";
$form = new codeworxtech\FormValidator('en');
$form->addValidation("Name","required","Name is mandatory.");
$form->addValidation("Email","email");
$form->addValidation("Email","required");
$form->addValidation("Comments","nourl");
if (!$form->ValidateForm()) {
$error_hash = $form->GetErrors();
foreach($error_hash as $inpname => $inp_err) {
echo "$inpname: $inp_err<br>\n";
}
echo "<br>\n<a href=\"javascript:history.back()\">Try again</a><br>\n";
}
}
?>
In $form->addValidation the first argument is the name of the input field in the form,
and the second argument is the validation rule that tells the type of the validation required.
There is a third optional argument and that is the error message to be displayed if the validation
fails. In the example above, "Name" is using a custom error message "Name is mandatory." while
the other fields are using the default from the language file.