#!/usr/local/bin/perl # Dilip Barman, http://www.cs.unc.edu/Courses/wwwp-f97/members/barman # Sep 20 1997 # # dbProcessChoice.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 form perlDatabase.html # 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"; # * * * 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 # print &PrintVariables(%input); # I'd rather format the printing myself: # while ( ($key,$value) = each(%input) ) # { print "\tThe value of the variable $key is $value\n"; } # To get a particular value, just look at $input{"xxx"} where xxx is the parmname $genre = $input{"genre"}; $whatToDo = $input{"whatToDo"}; # Print input values as a definition list # print "\n
\n
Genre
$genre \n
Task
$whatToDo\n<\dl>"; # * * * 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 web page title and top level header if ($whatToDo eq "Enquire") {$x = "Look up ";} else {$x = "Add to ";} print "Dilip's Music Database: $x $genre\n"; print "

Music Database: $x Music of Genre \"$genre\"

\n"; if ($whatToDo ne "Enquire") { &dbAddRecord; } # * * * W R A P U P H T M L * * * # Give option to return to try again or return home print "\n

Go back to main screen"; print "to add other genre records or retrieve records

"; print "\n
"; print "\n

Read"; print "\n"; print "\nproject proposal or system"; print "\n"; print "\nimplementation notes

"; print "\n

Return to Dilip's course "; print""; print "home page

"; print "\n
Background courtesy of "; print "\nMoyra's Web Jewels
"; # End HTML page print " "; # * * * S U B R O U T I N E S * * * sub dbAddRecord { # # dbAddRecord subroutine # Sep 20 1997 # This is called when we are adding a record of genre $genre. # We generate HTML for a form to ask for input on all the database # fields and call dbAddRecord.pl.cgi to add the record. The fields # we have are: # Title (key) # Artist # Format (CD, Cassette, Record, or Other) # Time (duration) # Comments # The fields are not error checked and nothing would stop # a user from entering a cost of "I don't know", for example. # By the way, the database is stored in a special DBM directory # where system:anyuser (like web clients) have write authority. # After taking input from the form, the following values are passed # to the dbAddRecord.pl.cgi to process: # genre (as passed in), title, artist, format, time, and comments print "\n

Please input the information about the new \'$genre\' addition to the collection."; print "\nAfter you add this entry, you can continue to add additional records"; print "\nof this genre. You can always go back to the"; print "\nmain screen to add"; print "\nrecords of another genre or retrieve records"; print "\n

"; print "\n

Title "; print "\n
Technically, each title should be unique. This is the name of the"; print "\nCD, tape, record, etc."; print "\n

Artist "; print "
Who performed the piece? Enter the name of the singer, group, etc. You"; print "\ncan also enter \"Various\" or even leave it blank."; print "\n

Format"; print " \n CD"; print " \n Cassette"; print " \n Record"; print " \n Other"; print "\n

Time "; print "\n
Enter the length, in minutes, of this recording. Don't"; print "\nworry if you don't know - leave it blank!"; print "\n

Comments "; print "\n
Optionally, enter any comments that you want to store with this entry."; print "\n


"; print "\n"; print "\n

"; print "\n

"; } # End dbAddRecord subroutine