The PHP for the Booking Form
Looking back in my code repository I last worked on the Hall Booking form in February 2020. The file was BWVH/booking_hall.php (I can click on this locally)
I realise that I did a lot of work on this! It was before I really took off on developing this website into what you see now. I have developed a way of documenting code.
Below is the top of the PHP file - I currrently have no intention of re-visiting it.
<?php
// This is the form for booking the village hall - due to limitation of the tsohosting this will be the "live" form and be run from tf/BWVH not bwvh.uk
// logic for sending email, logging event and display of response should be the same as tf_feedback.php
// define variables and set to empty values terms and conditions, Booking date and start time and the Nature of the
event are required here
// $tandcErr
$nameErr = $emailErr = $addErr = $telErr = $dateErr = $timeErr = $natureErr = $genErr = "";
$name = $email = $submit = $tel = $stime = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
Much of the code was found on various websites relating the processing and validation of forms.