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.
Packets, frames.
- Form/CGI interaction.
- Perl CGI programs.
- Ground rules.
- Lab.
Finish lab or more packets, frames? First project.
CGI application must generate more than a plain HTML document. Consider:
Content-Type: text/html\n\n
- Structure of an HTML document.
-
<BODY>
attributes.
-
<FORM>
structure:
- Attributes:
- Method:
POST: form parameters passed to application via STDIN. Safer.
GET: form parameters made a part of the action URL.
- Action: URL of the application which will process the form
data.
-
<INPUT>
:
- Text: name, size (of text box), maxlength (of input string).
- Submit.
- What data will be sent to the application? How many pieces of data?
- If the form fields read ``Tom'' and ``45,6'', what string is passed
to the application? (
name=Tom&list=45,6
)
- Accessing CGI.pm:
use CGI qw(:standard);
- Accessing the form parameters:
my $name = param("name");
Works for both POST and GET.
- Splitting the list of numbers:
@numbers = split(/,/, $list);
Splitting password file entries.
- Open CGI access is dangerous. Abuse will result in revocation of all
access.
- Inform me when you activate a new CGI program. Escalation: Warning,
lose privileges for X days, lose privileges for good.
- CGI programs must be formatted for human reading.
- 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.
Groups of two.
Thomas P. Kelliher
Wed Feb 9 12:23:55 EST 2000
Tom Kelliher