Sun Dial Menu
Validating Form Elements
Menu Validating Form Elements
 

Validating Form Elements

Having spent many hours on the development of Village Hall Booking and Rental forms they need to be documented.

The form elements are formatted to your prefered layout and the form submit button triggers the validation code. The html file is embedded in a PHP file along with the validation code. There are various methods you can use to ensure that the data entered into the INPUT elements is correct. Some data can be made mandatory and the format of the data can be check. i.e. dates and email addresses.

Additional checks can be made to ensure terms and conditions have been read.

Top

Example validation code

Checking an email address:

if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}

The individual checks on each INPUT elements are placed within a check function for the form submission request:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
.....
..... Validation code goes here....
.....
}

Links

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links toother websites.

The External link is disabled to on this page, please visit other pages

Unlike most genealogical research websites tempusfugit.me.uk does not attempt to get you to "sign-up" when you click on one of their links.

This Wikipedia link is disabled.

The link on Wikipedia was to:

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links to other websites.

The External link is disabled to on this page, please visit other pages

Top

External Links - references

Site design by Tempusfugit Web Design -