Introduction to Forms

This introduction covers the main form elements. It also explains the process that occurs when a form is submitted.

The main elements of forms are:

Form Elements

Text Fields and Text Areas

Radio Buttons

Check Boxes

Menu Buttons and Scrolling Lists

Submit and Reset Buttons

Processing Forms

Although forms could simply be used to display information, HTML provides them in order to supply a way for the user to interact with a Web server. The most widely used method to process the data submitted through a form is to send it to server-side software typically written in a scripting language, although any programming language can be used.

The figure below outlines the kind of processing that takes place.

  1. The user retrieves a document containing a form from a Web server.

  2. The user reads the Web page ...

  3. and interacts with the form it contains.

  4. Submitting the form sends the form data to the server for processing.

  5. The Web server passes the data to a CGI programme.

  6. The CGI software may use database information or store data in a server-side database.

  7. The CGI software may generate a new Web page ...

  8. for the server to return to the user.

  9. The user reads the new Web document ...

  10. and may interact with it.

Typically, form data is sent to a server (or to an email address) as a sequence of pairs, each pair being made up of a name and an associated value. The method that this data uses to arrive at its destination depends on the data encoding. Normally the pairs will be sent as binary-encoded characters, making them straightforward to process by software, and easy to read by humans. For example, an on-line store selling used computer parts might use a form when ordering second-hand disk drives; the form would send to the server for processing information identifying the manufacturer, the model name, and maybe quote price thus:

 manufacturer=syquest&model=ez135&price=45
      

This text represents a sequence of three name/value pairs. The names are manufacturer, model and price, and their associated values are syquest, ez135 and 45. There is nothing special about the names chosen or the way values are written, except that what is sent depends entirely on what the CGI software expects. If it expected maker, item, and cost, then the data from submitting the form would have to be:

 maker=syquest&item=ez135&cost=45
      

Quite simply, whatever the processing software expects determines what the HTML form must provide. Often the same person or team develops both form and CGI software, so this is usually of little concern.

Because of the standard way in which the server-side software that process form data is supplied with data, such software is usually referred to as a Common Gateway Interface (CGI) script. Quite often CGI scripts on Unix servers are written in a language called Perl, but languages such as Python are becoming popular; when complex or fast processing is required, C, C++ or Java may used.

To avoid server side programming when developing forms, and to avoid depending on scripts that may require considerable study, we will mostly use a different method of processing form information: email. In fact, it is very useful to submit form data to an email address, particularly in situations when the data should be seen by a human before being processed by software.

Review Questions

Do Review Questions 1-2.