Validating form php

by  |  28-Aug-2016 16:50

The class will return false if the validation failed.In this post, you’ll learn – How to Validate Forms with PHP and it will be a server side form validation.All fields are required, except those marked optional.

validating form php-31validating form php-80

The source code for this example (zip) is available.

This class is meant to validate data entered in forms. To specify a field to validate it requires the field name and, in some cases, other arguments.

All we need to do is check for an error message and display it on the page: Again, a more advanced version would place the error message next to the affected field, and do this for multiple fields at once.

In the demonstration above we've included the error message at the top of the form.

Naturally there's much, much more in Clonefish - make sure you take the tour and check the examples!

Community Discussion