This is an example of a form, do not click on the submit button, as it will do nothing.
The syntax for the above is:
<FORM ACTION="http://YourCGIScript" METHOD="POST">
<TEXTAREA NAME="variable name" ROWS="3" COLS="40">Enter your name.</TEXTAREA><BR>
<INPUT TYPE="checkbox" NAME="fonts" VALUE="font">fonts<BR>
<INPUT TYPE="radio" NAME="colors" VALUE="color">
<INPUT TYPE="Submit" VALUE="default value"><BR>
<INPUT TYPE="Reset" VALUE="default value">
</FORM>
Forms allow the user to input data and submit it to you to use. Forms are limited in that not only does the viewers browser need to support forms, but the server has to as well. Forms involve two way communication. This communication relies on CGI to enablethe communication. The action attribut in the <FORM> tag specifies a URL that indicates a specific CGI script or program which collects the form data. There is also the METHOD attribute which describes the way the input data is delivered to the form's handling program or CGI script. The following are examples of the various input tags that you can use. The syntax is on the left, and an example of the output is on the right.
<INPUT TYPE="text" NAME="var name" SIZE="10" MAXLENGTH="80" VALUE="default value">text box | text box |
<INPUT TYPE="password" NAME="var name" SIZE="10" MAXLENGTH="80" VALUE="default value">password box | password box |
<INPUT TYPE="checkbox" NAME="var name" VALUE="default value">checkbox | checkbox |
<INPUT TYPE="radio" NAME="var name" VALUE="default value">radio button | radio button |
<INPUT TYPE="submit" VALUE="Submit"> | |
<INPUT TYPE="Reset" VALUE="Reset"> | |
<TEXTAREA NAME="variable name" ROWS="1" COLS="10">Enter text here</TEXTAREA> | |
<INPUT TYPE="hidden" NAME="var name" VALUE=""> <SELECT NAME="variable name"> <OPTION>click the down arrow <OPTION>Just <OPTION>examples <OPTION>here </SELECT> |
You can use any combination of checkboxes, and radio buttons, that you would like. The VALUE attribute is used by the CGI script to pull information from the form. CGI stands for Common Gateway Interface. Cgi is an interface between the viewer/client and the server/host computer. The script allows for interaction between the two. The form is a method of input, and the script pulls the information from the form, and routes it back to your server. NOTE: Your server must be capable of using CGI script. You will not be able to use forms to obtain information if it is not, as your server will not know what to do with the information in the form... There are a number of programs that you can use to code your CGI, eg. Perl and C++... Here are a couple of fragment examples to show you what the code is like: (these examples are written in Perl and assume that the METHOD=post)
example 1.
#this reads input stream from standard input
#device (STD) into the buffer variable $buffer, using
#the environment variable CONTENT_LENGTH to know how
#much data to read.
read (STD IN, $buffer, $ENV{'CONTENT_LENGTH'})
example 2.
#split the name value pairs an '&'
@pairs = split (/&1, $buffer);