DOCUMENTATION

  • Validation
Search »

Adding Validation

Next, we need to put the two together: add the validation rules to our form and validate the form submission. This step works by sandwiching the validation rules and function call into the PHP at the top, to prevent the ft_api_process_form() function automatically redirecting when the form is submitted.

Note that we've also added in some PHP into the form itself. That code will automatically re-enter the form submission values that have been already entered. N.B. the "@" character that appears before the variables may look unfamiliar. All it does is suppress PHP warnings / notices that usually show up if the variable isn't already defined; e.g. on the first time the user loads the page.