Goals
In this session you will:
- parse form data
- use cgi-lib.pl
POST
- log into your Solaris workstation
ssh into emperor.mousetrap.net
- go to your virtual webserver's directory
- review the logs in your
logs directory.
- make a new CGI application, called
day1post.cgi. The application should:
- have a title
- have a level-1 heading
- print out which browser (user agent) the user has.
- run it from the command line
- run it from the browser.
- view the html source from your browser.
- debug as needed. When you've got it running, leave the results in your browser for proof.
simple forms
retrieving a query string
my $cgiInput = $ENV{'QUERY_STRING'};
retrieving input from STDIN
read(STDIN, $cgiInput, $ENV{'CONTENT_LENGTH'};
parsing the input by hand
- decode:
$cgiInput =~ s/(%[\dA-Fa-f][\dA-Fa-f])/pack ("C", hex $1)/eg;
- encode:
$string =~ s/(\W)/sprintf("%%%x", ord($1))/eg;
- split
leveraging cgi code libraries
working with your parsed data
Homework
Spend 10 minutes with an SQL tutorial.
http://www.mousetrap.net/syllabus/cgiperl/day2.html
$Id: day2.orb,v 1.7 2002/08/23 18:26:39 mouse Exp $
Remember, your login is based on your machine's hostname, not on any other number.
~/[initials] refers to the subdirectory under your homedir, named after your initials. Everything except for .dotfiles will be stored in your ~/[initials] directory.