next up previous contents index
Next: Form processing Up: HTML Previous: Common markup tags   Contents   Index


Form tags

There are also special form tags that will render in a browser elements useful to gather information from a user. A form is specied as
<form method="get" 
      action="http://wherever.com/cgi-bin/process.cgi"
      enctype="application/x-www-form-urlencoded">
<!-- Various form elements follow
-->
</form>
where the (optional) attributes illustrated are Some examples of form elements are listed below. For each such element there are two important aspects - the name of the element, which is used as a label for that piece of data, and the value, which is the value the user has filled out for that particular element. To see how form data gets sent (via the get method), visit http://www.google.ca/, type in some search term, and press the Google Search button. The page displaying the results will have in the address bar a location such as
http://www.google.ca/search?q=Perl+rules&ie=UTF-8&hl=en
which has been truncated to fit on one line. What this address means is that the script processing the data (http://www.google.ca/search), has received some form elements in the form of a query string, which is everything that appears after the ? in the address. The query string is a series of name=value pairs, separated by the & symbol (or, in some cases, a semicolon ;). In this case there are three form elements, q, ie, and hl, which for this search have taken on values Perl+rules, UTF-8, and en, respectively.
next up previous contents index
Next: Form processing Up: HTML Previous: Common markup tags   Contents   Index