HTML Forms

Before we examine the specifics of CGI, it is useful to review the most common method by which end users are presented with an interface to CGI programs: HTML forms. Forms are a part of the HTML markup language that enable fields of different types to be presented to the end user. Then data entered into the fields can be sent back to the web server. The fields can be lines or boxes of text or buttons which can be pushed or checked by the user. The following is an example of an HTML page that contains a form:

<HTML><HEAD><TITLE>My Forms Page</title></head>
<BODY>
<p>This is a page with a form.
<p><FORM ACTION="mycgi.cgi" METHOD=POST>
Enter your name: <INPUT NAME="firstname" SIZE=40><br>
<INPUT TYPE=SUBMIT VALUE="Submit Form">
</form>
</body></html>

This form creates a line 40 characters long into which the user can enter a first name. Underneath the input line is a button which, when clicked, will submit the form information to the server. The forms-related tags that are supported by HTML 3.2—currently the most widespread standard—are listed below. Incidentally, names of tags and attributes are case-insensitive. We adhere to the convention of using uppercase for opening tags and lowercase for closing tags, but that’s just one way of doing it.

<FORM>

This tag indicates the beginning of a form. At the end of the form the closing </Form> is required. Within the <FORM> tag, three attributes are possible: ACTION gives the URL or relative path name of the CGI program to which the ...

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.