squeak!
Syllabus Homepage
Course Overview
Course resources
Day 1
Day 2
Day 3
Day 4
Common errors
Internet Glossary
About Your Instructor
Credits: This site powered by the vi text editor, apache webserver, perl scripting, and Debian linux.
squeak!

cgiperl - Day 2

Goals

In this session you will:
  • parse form data
  • use cgi-lib.pl

POST

  1. log into your Solaris workstation
  2. ssh into emperor.mousetrap.net
  3. go to your virtual webserver's directory

  4. review the logs in your logs directory.

  5. 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.
  6. run it from the command line
  7. run it from the browser.
  8. view the html source from your browser.
  9. debug as needed. When you've got it running, leave the results in your browser for proof.

simple forms

  • ACTION
  • GET v. POST

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

  • logging
  • sending email

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.


© 1995-2001 jason carr
Distributed under the terms of the GNU Free Documentation License.