If you are going to be creating web forms, it is beneficial to understand what is happening behind the scenes. This example traces the steps of a transaction using a simple form that gathers names and email addresses for a mailing list; however, it is typical of the process for many forms.
- Your visitor, let’s call her Sally, opens the page with a web form in the browser window.
The browser sees the form control elements in the markup and renders them with the appropriate form controls on the page, including two text entry fields and a submit button (shown in Figure 9-1).
- Sally would like to sign up for this mailing list, so she enters her name and email address into the fields and submits the form by hitting the “Submit” button.
- The browser collects the information she entered, encodes it (see the sidebar A Word About Encoding), and sends it to the web application on the server.
- The web application accepts the information and processes it (that is, does whatever it is programmed to do with it). In this example, the name and email address are added to a database.
- The web application also returns a response. The kind of response sent back depends on the content and purpose of the form.
Here, the response is a simple web page that contains a thank you for signing up for the mailing list. Other applications might respond by reloading the HTML form page with updated information, by moving the user on to another related form page, or by issuing an error message if the form is not filled out correctly, to name only a few examples.
- The server sends the web application’s response back to the browser where it is displayed. Sally can see that the form worked and that she has been added to the mailing list.