Form/CGI Interaction

Tom Kelliher, CS 318

Feb. 9, 2000



Online resources for HTML, Perl, CGI.


Do some of the examples from the tutorial on your own.

From Last Time

Packets, frames.


  1. Form/CGI interaction.

  2. Perl CGI programs.

  3. Ground rules.

  4. Lab.

Coming Up

Finish lab or more packets, frames? First project.

Form/CGI Interaction

CGI application must generate more than a plain HTML document. Consider:
Content-Type: text/html\n\n

MinMax Form Example

  1. Structure of an HTML document.

  2. <BODY> attributes.

  3. <FORM> structure:
    1. Attributes:
      1. Method:

        POST: form parameters passed to application via STDIN. Safer.

        GET: form parameters made a part of the action URL.

      2. Action: URL of the application which will process the form data.

    2. <INPUT>:
      1. Text: name, size (of text box), maxlength (of input string).

      2. Submit.

minmax.html Example

  1. What data will be sent to the application? How many pieces of data?

  2. If the form fields read ``Tom'' and ``45,6'', what string is passed to the application? (name=Tom&list=45,6)

Perl CGI Programs

  1. Accessing
    use CGI qw(:standard);

  2. Accessing the form parameters:
    my $name = param("name");
    Works for both POST and GET.

  3. Splitting the list of numbers:
    @numbers = split(/,/, $list);
    Splitting password file entries.

CGI, HTML Ground Rules

  1. Open CGI access is dangerous. Abuse will result in revocation of all access.

  2. Inform me when you activate a new CGI program. Escalation: Warning, lose privileges for X days, lose privileges for good.

  3. CGI programs must be formatted for human reading.

  4. I expect all HTML code handed in for grading to be written by hand and to be formatted for human reading. Any machine-generated HTML turned in for grading, without permission, will be a violation of the Honor Code.

MinMax Lab

Groups of two.

Thomas P. Kelliher
Wed Feb 9 12:23:55 EST 2000
Tom Kelliher