HTML provides a means for users to enter information and pass it on. HTML itself cannot process the information so it must be passed to a script, for example JavaScript, on the client side or PHP or Perl on the server side.
A form begins with the <form> element followed by the contents of the form and a corresponding end tag. As well as the form controls, a form can contain body text and other HTML elements. Multiple forms can appear on one page but nesting is not allowed i.e. they cannot overlap.
Name/Value Pairs
When data is passed from a form to a script it's passed as name/value pairs as in name=value, where name is the name of a form control and value is the value that the control is set to.
The <form> element has a number of attributes some of which are listed below.
The action element is used to specify the URL, or address, of the script that will receive the data. The URL may be absolute or relative.
The method element defines the method used to send the data and is either post or get.
Post is the most used method since it doesn't limit the amount of data (unlike the get method) and doesn't append the data as a query string onto the URL.
Get is less used since it does append the data as a query string onto the URL and limits the data to 2048 characters, less any characters required to build the query string. However, a get URL with query string can be bookmarked, unlike with the post method, so is used on search pages for this reason.
A form can enclose a number of elements that include.
The input element which allows a number or controls including text, password, hidden, radio button, checkbox and file.
The textarea element which allows a multi-line text area.
The select and option elements which allow the user to make choices from a drop down select list.