PHPMailer-FVE (Form Validate and Email) is a class merged from two separate products: FormValidator and PHPMailer-FE. The product came about originally as a suggestion from a user. In considering the project, I thought about how I always used FormValidator and PHPMailer-FE together - never separately. The user's suggestion was not only valid, it was apparent -- I still can't figure out how I didn't see that myself.
In creating the project, all of the rules have been updated, support for longer TLD names has been included.
Is a class with form validation still needed? Clearly there are several technologies available for form validation. The Javascript (or JQuery) version are all popular. They are, however, a technology that is implemented in the user's computer - front-end strategies. As long as the user's computer is part of the solution, it is open for interruption and hacking at the local level. It can even be disabled. PHPMailer-FVE is a back-end strategy. That is, implementation is on the server ... not easily accessed by hackers in real time. PHPMailer-FVE provides the most secure and robust validation available. It's a server strategy with a unique capability: if the form validation fails, the user is returned to the form with data intact (no retyping). User-friendly too!
More info coming soon, in the meatime, here's some info about FormValidator:
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.