#!/usr/local/bin/perl # Dilip Barman, http://www.cs.unc.edu/Courses/wwwp-f97/members/barman # Sep 21 1997 # # dbAddRecord.pl.cgi: As part of my perl programming project, described # at www.cs.unc.edu/Courses/wwwp-f97/members/barman/perlProjectProposal.html, # this perl cgi-bin script is called from the HTML generated in # dbProcessChoice.pl.cgi to add a record. All this does is inserts # the record into the database. Input parameters are set in STDIN: # . . . # to process the input. Using POST, these input variables are set in # STDIN: genre and whatToDo (set to either Enquire or AddRecord). # genre indicates the musical genre of interest (e.g., "Jazz - contemporary" # or "Rock"), whatToDo = Enquire means we are to return a list of music # in that genre, and whatToDo = AddRecord means we are to add a record. # We start off by including a nice library file by Steven Brenner which does # lots of things for us require "/afs/cs.unc.edu/project/courses/190-25f97/programs/perl/lib/cgi-lib.pl"; # GLOBAL VARIABLES $FALSE = 0; $TRUE = 1; $DBFILENAME = "../musicDatabase/musicDB"; # name of DBM database file $ROACCESS = "0555"; # Read-Only open: RWX, so U=101, G=101, O=101 $RWACCESS = "0777"; # Read-Write open: 111 111 111 # Remember to set AFS directory permissions so system:anyuser (a web # client, for example) has write privilege to this directory -- # fs setat ../musicDatabase system:anyuser write $RECDELIMSTART = "\*\$\["; # delimit record entries: *$[ ... ]$* $RECDELIMEND = "\]\$\*"; # * * * P R O C E S S U S E R I N P U T * * * # Get user input &ReadParse(*input); # Store input as attrib-value keys in variable input $title = $input{"title"}; $artist = $input{"artist"}; $format = $input{"format"}; $time = $input{"time"}; $comments = $input{"comments"}; # * * * T O P L E V E L H T M L S T U F F * * * # Okay, since this is run from the web, we have to first send back # http header information - and there is a library function to do it print &PrintHeader; print "
"; print "You did not specify a title. The title is";
print "\n(the only field that is)