HTML from

Form is an HTML element. A form is used to accept data from the user side. A very common example of use of form is a login form of your email account. When you enter your login name and password, and click the submit button your submitted data (i.e. user name and password) are sent to the server of the service provider. Server then validates those data and displays the messages of your account.

Form input elements

A form holds few input elements to accept user input and to submit them. Few common types of such elements are Textbox, Textarea, password field, Submit button, Reset button, Dropdown combo box, etc. They are the members of the form in which they are placed. The roles of those elements are listed below.

  • Textboxes and Textareas (multi line text box) are used to accept text data.
  • A password field is used to accept user password. The difference between a normal Textbox and a password field is that, for a password web browser takes special care to this input. You can't read or copy the typed text here; instead you will see a symbolic representation of characters (a series of dot) on it.
  • A dropdown combo commonly known as Select input is used to select an item from a predefined set of values. You often see such elements when you select your country of residence in an HTML form. There are lots of country name are listed in a dropdown box and you have to select your country. Here you can't type any custom data like a Textbox.
  • A reset button is used to delete all the input data supplied by the user. On clicking this button the form return to its initial state.
  • As the name implied a submit button is used to submit a form. On clicking this button all the form data supplied by the user are then transmitted to the server for further processing.
  • There are also other input elements (File input, Hidden input, etc.), which a form may have. But their role is beyond the scope of this article.

Properties of HTML form

Tow most common and important properties of an HTML form are "action" and "method". The action property define the URL where the form to be submitted. Say a form is to be submitted to an URL http://ramui.com/submit.php. Then the page submit.php must have proper code to handle those submitted data and take necessary action.

The method property define the way how the data are to be transmitted to the server. It may be GET or POST.

GET and POST

As said earlier form data can be submitted either by GET or by POST method. In GET method data hold by the form fields are first encoded and then transferred to the server through query string. As query string is part of URL so data security in this method is very poor. Anyone can see your submitted data just by searching history of your browser. So 'GET' method of form submit is only used when data security is not a big issue. Another limitation of GET method is that you can submit only ASCII data. POST method is a method of submitting form data in the header of an HTTP request.

GET or POST whatever the method used browser takes all responsibility either to build query string (in case of GET method) or build proper header request (in case of POST method). Developers have nothing to do here. They only mention the method of submission within the form tag and at the server end receive and handle those data carefully.

Comments:

Add comment