HTML/CGI Talk
CGI

Foms?

Normal 'fill-out' forms can be emulated in HTML. It is simple to do and easy to use.

Forms can contain input boxes, lists, radio buttons etc.

However, HTML forms are useless on their own...

CGI?

Common Gateway Interface
CGI is the language between HTML files and applications.

These applications can be writen in any language and on any platform, however they are simplest to write in PERL in Unix (woops, Linux).

Basically it is a standard for passing information. This information includes fields from an HTML form and server / client information (user, client address etc).

Form Elements

Basic Structure

As with all HTML, a form is a container.
	<FORM METHOD=GET ACTION="/cgi-bin/luv/email.cgi">
	some stuff in the middle...
	</FORM>
METHOD must bet GET or POST. GET uses the environmenent variable QUERY_STRING to retun information to your application, while POST retuns STDIN (standard input).

ENCTYPE specified encoding. This attribute only applies if METHOD is set to POST but at this stage can only be application/x-www-form-urlencoded).

INPUT

The input structure is the most important and the most used. It is the basic method of getting information.

Basic structure = <INPUT TYPE=? NAME=? VALUE=? CHECKED=? SIZE=? MAXLENGTH=?>

Elements:

Select

Used to create a list or menu
	<SELECT name="my list">
	<OPTION>First option
	<OPTION>Second...
	</SELECT>

TEXT Area

        <TEXTAREA NAME="foo" ROWS=4 COLS=40>
        Default contents go here.
        </TEXTAREA>

What happens next

The information is then gathered and sent to your application. The method we are going to concentrate on is GET. POST uses STDIN which means you can not create an ANCHOR/Link with parameters.

For example, here is a link to a directory script about me.

This was used to call the above script.

http://www.pas.com.au/cgi-bin/whois.cgi?scottp
As you can see there is a ? at the end of the URL. Following this is a string which is passed to the application via the environment variable QUERY_STRING.

It is then up to your application to remove the information and use it.

What happens next on your viewer

All OUTPUT from your script is captured by the HTTP Server and returned to your viewer.

Contents | Previous | Next | Search

Modified: 1/8/95
Created: 28/7/95
By: scottp@pas.com.au