HTML Forms are used to select different kinds of user input.
A web form has two parts: the HTML ‘front end’ and a back end form processor. The HTML front end part handles the presentation while the back end handles the form submissions (like saving the form submissions, sending emails etc).
The back end form processor script is usually written in languages like PHP, ASP or Perl.
The image below illustrates the concept:
- A visitor visits a web page that contains a form.
- The web browser displays the HTML form.
- The visitor fills in the form and submits
- The browser sends the submitted form data to the web server
- A form processor script running on the web server processes the form data
- A response page is sent back to the browser.
All the input elements should be enclosed within the opening and closing <form> tags like this:
The input elements go here….
The following are the attributes of the form tag:
action=”Link to the form processor script”
The action attribute points to the server side script (the ‘back end’) that handles the form submission. Usually, this will be a script (PHP,ASP, Perl) or a CGI program
method =get|post ( either GET or POST)
In simple terms, if you use GET method, the form submission values are passed as part of the URL. 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 taken by default.