Intro to HTML Forms
Forms add the dimension of interactivity, that bring the Web to life. pages can be glitzy and glamorous, but without forms, they are "read-only". Forms let the user write back to you with comments or specify database search criteria.
<FORM METHOD="POST" ACTION="/cgi-bin/web-exe"> Form elements and other HTML </FORM>
| Attribute | Description |
|---|---|
| METHOD | Specifies the HTTP method used to send the request. This can be either GET or POST |
| ACTION | Specifies the URL of a script that will process the user-defined data. We will talk about "Scripts" tomorrow. But for now, let's just focus on getting user data to the server. Note that if no action is specified, it will default to the current page. |
| ENCTYPE | Specifies the way in which the form data is encoded before it is sent to the server. This defaults to application/x-www-form-urlencoded |
<FORM METHOD = "POST"
ACTION = "/cgi-bin/script.cgi">
</FORM>
<FORM Method="GET|POST" Action="URL"
>
</FORM>
| a Form with a CGI program at URL |
|---|---|
<INPUT
Name="name" Type="
text |
hidden |
password |
image |
submit |
reset |
checkbox |
radio ">
| Input widget with symbolic name, name |
<TEXTAREA
Name="name" Rows="R" Cols="C">
| Text area (lines of editable text) with symbolic name, name and R rows and C columns visible at a time. |
<SELECT
Name="name" [Size="N"] [Multiple]>
|
Select element with symbolic name, name,
N selections visible at a time;
multiple
selections possible;
selections defined using |
<OPTION Value="string"> text
|
Option element used with SELECT;
with returned value string or text if not provided.
|
The INPUT tag: . This is the most important of the form elements; with it you can allow the user to input text or passwords and submit them to the server for CGI processing.
The <Input> Tag
<INPUT TYPE = "TEXT" NAME = "fname">