#!/usr/local/bin/perl use CGI; use CGI::Carp qw/fatalsToBrowser/; require "parseform.lib"; &parseform; &variables; if ($preference eq "") {&error1;} elsif ($name eq "") {&error2;} elsif (($songs[0] eq "") || ($bands[0] eq "")) {&error3;} else {&confirmation;} &print_results; &email; sub variables { $name=$formdata{'name'}; $email=$formdata{'email'}; @songs=($formdata{'song1'}, $formdata{'song2'}, $formdata{'song3'}, $formdata{'song4'}, $formdata{'song5'}, $formdata{'song6'}, $formdata{'song7'}, $formdata{'song8'}, $formdata{'song9'}, $formdata{'song10'}); @bands=($formdata{'band1'}, $formdata{'band2'}, $formdata{'band3'}, $formdata{'band4'}, $formdata{'band5'},$formdata{'band6'}, $formdata{'band7'}, $formdata{'band8'}, $formdata{'band9'}, $formdata{'band10'}); $preference=$formdata{'preference'}; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); @months= qw(January February March April May June July August September October November December); %music=($songs[0], $bands[0], $songs[1], $bands[1], $songs[2], $bands[2], $songs[3], $bands[3], $songs[4], $bands[4], $songs[5], $bands[5], $songs[6], $bands[6], $songs[7], $bands[7], $songs[8], $bands[8], $songs[9], $bands[9]); $bq="
"; $ebq="
"; } sub print_results { $results="/home/thestark/public_html/mensclub/results.cfm"; open(RESULTS, ">> $results"); print RESULTS "

$name's Desert Island Mix CD, \n"; print RESULTS "posted on $months[$mon] $mday, 2001.

\n"; print RESULTS "$bq $bq $bq $bq $bq $bq\n"; if ($preference eq "yes") {&ordered;} if ($preference eq "no") {&unordered;} sub ordered { print RESULTS "
    \n"; foreach $song (@songs) { print RESULTS "
  1. $song by $music{$song}\n"; } print RESULTS "
\n"; } sub unordered { print RESULTS "\n"; } print RESULTS "$ebq $ebq $ebq $ebq $ebq $ebq\n"; print RESULTS "
\n"; close(RESULTS); } sub email { $mail="/usr/lib/sendmail"; open(MAIL, "|/usr/lib/sendmail -t") || &errormsg; print MAIL "To: thestark\@verizon.net \nFrom: The Men's Club\n"; print MAIL "Subject: Desert Island Disc Received from $name\n"; print MAIL "$name ($email), using $ENV{'HTTP_USER_AGENT'} browser/platform, has submitted a desert island disc!\n"; if ($preference eq "yes") {&ordered;} if ($preference eq "no") {&unordered;} sub ordered { print MAIL "
    \n"; foreach $song (@songs) { print MAIL "
  1. $song by $music{$song}\n"; } print MAIL "
\n"; } sub unordered { print MAIL "\n"; } close(MAIL); } sub confirmation { print "Content-type: text/html \n\n"; print <<"HTML code"; Thank You!

Here are your picks for your Desert Island Mix CD:

HTML code if ($preference eq "yes") {&ordered2;} if ($preference eq "no") {&unordered2;} sub ordered2 { print "
    "; foreach $song (@songs) { print "
  1. $song by $music{$song}"; } print "
"; } sub unordered2 { print ""; } print "Thanks for your submission, $name! Your tracklisting will now also be posted here!"; } sub error1 { print "Content-type: text/html \n\n"; print <<"HTML code"; You didn't select your preference!


Go back and choose whether or not your choices are in order. HTML code } sub error2 { print "Content-type: text/html \n\n"; print <<"HTML code"; You didn't put your name!


Go back and enter your name. HTML code } sub error3 { print "Content-type: text/html \n\n"; print <<"HTML code"; You didn't put any songs!


Go back and please put at least one song and artist. HTML code } exit;