University of Baltimore
Merrick School of Business
Simple CGI for form processing
- Your first task is to design a form for the UB Programing Club (note: this is a fictitious club). Use UB Programming Club as a Heading and Join the Club as a sub-header, add the UB gif to the page, draw a horizontal rule (line) and create input areas (each one in a line) for name, address, e-mail address, username and password. This form would be used to allow students join the club on the Web.
- Your second task is to write a CGI (Perl script) which uses the input provided by the form, encrypts the password, and write this info to a members.txt file.
- I suggest you do a file layout by hand and select the key to the file (in this case username is a good candidate).
- then create a Perl script which reads simple input variables for the fields you are going to read from the form, e.g. $uname, $passwd, etc.,encrypts the password, and writes these values to the file members.txt.
- be sure your program does not create duplicates in the members.txt file (hint: first create a program that only writes into the members.txt file. Later modify it to read the input, read the file and if no match then add).
- once this is working, convert the script into a CGI using require "cgi-lib.pl"; and its subroutine &ReadParse; as seen in class for the bugreport.pl script, particularly in the WriteReport Subroutine.
- Modify the script using the &MethGet subroutine of cgi-lib.pl to return the form you created if the method is get, or to write to the members.txt file if the method is post. The method will be get if there is a direct link to the URL of the script; the method will be post if you fill in the form and submit it.
- Test your CGI in the apache installation you did in assignment 1. The CGI script should be placed in the cgi-bin subdirectory of the Apache server. The form file should go in the htdocs directory (Windows) or html directory (Linux).
- When you are done read these instructions on how to submit a copy of the form and CGI script you created as your assignment 3 (A3).
This page is maintained by Al Bento who can be reached at abento@UBmail.ubalt.edu
This page was last updated on August 20, 2002. Although we will attempt to keep this information accurate, we can not guarantee the accuracy of the information provided.