Many sites feature web forms to collect information from users. Unfortunately, these forms often provide a poor experience for the user, with predictable results. This article will show you how to make filling out web forms more fun (or at least less painful) for your users with the help of PHP and some AJAX magic.
One of the most important requirements for PHP web forms is usability; it's the goal of many web designers to improve the user's experience. With classic PHP web forms, a user is required to enter information in the form and then press the submit button. The PHP script will then validate the data entry to make sure the user has entered the correct information -- if it is correct, the user will then be taken to a new page (a success page, for example).
However, things can get a bit uncomfortable in the classic PHP web form when a data entry mistake occurs. If a mistake occurs, PHP will output error messages on the other pages, and the user will be required to type all the information in over and over again. This might be OK for shorter web forms, but it is inefficient for longer web forms (such as a sign up form on large websites where lots of fields are required like the address, phone number, birthday, etc).
The obvious result of this process is a poor user experience. If your web form is not user-friendly, users will avoid your website, and worse, this will affect your sales.
With the use of AJAX, PHP web forms can be made as user friendly as possible. In this article, I will show how to use AJAX technology along with PHP to make user friendly web forms that satisfy the requirements listed below:
1. If a mistake occurs, accurate feedback from the server will be shown to the user, pinpointing where the exact data entry mistake occurred.
2. If a mistake occurs, aside from giving accurate feedback, the user will not need to type in all the fields all over again. This means the page will not be reloaded or refreshed.
3. If there is no mistake or the user successfully enters all the information correctly, the correct information can be shown.