HTML Forms
What we have learned so far has been helpful for displaying information on our web page. But sometimes we might want to make our pages more interactive, and get information from the user. This is particularly useful if you are selling something, or you want to have a guestbook on your site, take a survey, etc. All of these require that the user sends us information that we do something with. Forms will help us accomplish this.
A form consists of two parts:
1. The basic form within form tags <FORM> that contains the text boxes, checkboxes, radio buttons, menus, clickable images. We will go into these in more detail on the next few pages.
2. A script that processes the information and converts it into a format that we can use. Scripts, usually CGI or ASP, are written in other programming languages, such as Perl, C++, JavaScript, or VBScript. They are small programs that send the information from your form to the server. You can write your own, or find many ready-to-use scripts on the web.
Although scripts are beyond the scope of this tutorial, it is important that you understand how the information is sent to the server. All of the information to be included in the form must go inside the form tags <FORM> ... </FORM>. There are two attributes that we must specify. One is the METHOD, the other is the ACTION.
There are only two possible values for the METHOD attribute: GET or POST. GET is typically used with single responses. It works by adding the information from the form field to the end of the URL that is sent to the server. POST is more popular, because it allows us to send a larger amount of data - there is no limit
The ACTION attribute is simply the URL for the script that will process the form data. The form containers will look like this:
<form method ="post_or_get" action="URL to script">
...
</form>We can't really do anything with this yet, though. We need something to send, and a way to tell the browser we're ready to send it.
Let's add some content to our form!