While most other HTML elements are used to present information on your page, an HTML form is used to gather information from your users.

Most modern websites will interact with their users through forms. For example, you will need to have a form to allow users to place orders, send you a message, or track their orders.

How does a form work?

The form itself does not process the input. It only gathers input from the user and sends the information back to the webserver.

To process information from a form, you will need to use server side programming such as CGI, Perl, ASP, PHP.  For ASP.NET, HTML forms can be used, but there are better options to interact with users (ASP.NET topics are covered in their own series of tutorials).

The following interactive process takes place when a user accesses a page that contains a form:

  • The visitor fills in the form and submitsThe browser sends the submitted form data to the web serverA form processor is running on the web server processes the form dataA response page is sent back in HTML to the browser

Form Element

A form can contain input elements of type such as text boxes, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, text area, fieldset, legend, and label elements. A starting and ending

tag is used to create a form.

... input elements ...

There are several attributes that you can assign to the form element. However, the only required attribute is action. The action attribute points to the server side script that handles the form submission. Another optional attribute that is commonly used is method.

You assign the method attribute to either GET or POST. If you use GET method, the form submission values are passed as part of the URL (QueryString).

If it is POST, the information is sent to the server as part of the data body and will not be visible in the URL box in the user’s browser. If you don’t specify the method, GET is used by default. Here is an example.

... input elements ...

Now that you have your form, you need to add input elements. As discussed earlier, input elements include text boxes, checkboxes, radio, and buttons.

Input Element

The element is used to gather information. An input element can vary in many ways, depending on the type attribute. An input element can be of type text, checkbox, password, radio, reset, and submit.

Here are some examples:

textbox1: 
textbox2: 

textbox1: textbox2:

Password: 

Password:

Yes
No

Yes No

A
B
C

A B C

Name: 

Name:

A submit button is used to send form data to the web server. The data is sent to the page specified in the form’s action attribute. The action page will run the code against the data and return the results back to the user.

Name: 

Name: