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.
Example validation code
Checking an email address:
$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:
.....
..... Validation code goes here....
.....
}