HTML and CSS Reference
Think of forms as the HTML equivalent of an intermediary for your data, located
between you and the web page's server.
A form consists of a form element that establishes a container around any number
of “form controls” (form HTML elements for gathering input) as well as any other body
markup such as paragraphs and other flow content (however, having one form nested in-
side another is not allowed). Below all the input form controls will be a button of some
sort for submitting the form—sending the entered data off to the server. Forms can send
data using two different methods: GET and POST. The most obvious difference between
these methods is that when using the GET method, the data from a form submission ap-
pears in the website's address URL. For example, the URL of a form submitted using
the GET method might look like this:
which could have been the result of submitting the form in Figure 4-1 .
Figure 4-1. A simple web form for gathering user input
For this form, the HTML may look like this:
<form method="get" action="handle_form.php">
<p><label>Name: <input name="name" /></label></p>
This example uses a PHP script to process the form, but plenty of other server-side
languages could be used such as ASP.NET, Python, or others. In the case of PHP, there
are three “superglobal” variables that allow it to access the data submitted in a form.
The variables $_GET and $_POST get access to form data submitted via the GET and
POST methods, respectively, while $_REQUEST acts as a container for all data submit-