v. Server-side Validation
Modify tma02_validate.php to provide server-side validation for the ‘booking reference’ field.
(8 marks)
Although the client-side validation checks the correct form of the booking reference, it does not actually check if it is a valid booking reference.
For a reference to be valid, the server-side should validate the reference to the same format as the client-side, plus the following additional constraints: the three-letter group must be one of “EGH”, “ONL”, “DSC”. Anything else is invalid.
The next character must be a forward slash (/). Anything else is invalid.
The first digit may only be 1 or 2. The other digits may be any value between 0 and 9 inclusive.
You need to provide checks and only if all are valid, proceed to write the data to the database. If not, provide feedback to the user that the booking reference is invalid.
Add a comment to your validation code explaining the meaning of each part of your booking reference validation expression.
Again, examine the existing code closely, it will guide you.
The easiest way to test regular expressions is using a free online tool – search the web for ‘regex tester’ to discover these.