I am trying to append to an existing database and my cgi keeps coming up
with an Internal Server Error. I've looked this over many times with
different books as references, and I can't see what is wrong with it. My
form method is POST. Here is my code:

#!/usr/bin/perl
require("cgi-lib.pl");
print "Content-type: text/html\n\n";
unless(open(DAT, ">>timesheet.db")){
        die, "Cannot Open File: timesheet.db" };
print "<html><head><title>Timesheet</title></head>\n";
print "<body>\n";
print "<img src=\"../img/head.gif\">\n";
$nothing = ' ';
$choose = 'CHOOSE ONE';
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/^\s+//;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}
$name = uc $FORM{'name'};
$date = uc $FORM{'date'};
$job = uc $FORM{'job'};
$customer = uc $FORM{'customer'};
$task = uc $FORM{'task'};
$service = uc $FORM{'service'};
$hours = uc $FORM{'hours'};
$desc = uc $FORM{'desc'};
if ($name == $choose or $date == $nothing or $job == $nothing or $customer
== $nothing or $task == $nothing or $service == $choose or $hours ==
$nothing or $desc == $nothing) {
        print "Please make sure ALL field are filled in.\n";
        print "<a href=\"../timesheet/timesheet.html\">BACK</a>\n";
        print "</body></html>\n";
        close DAT;
        exit; }
else {
        print "Timesheet for $name on $date written to file successfully.\n";
        print "</body></html>\n";
        print DAT "$name,$date,$job,$customer,$task,$service,$hours,$desc\n";
}
close DAT;
exit(0);

If anybody has any ideas, I'd appreciate the help.

Thanks,

Shawn

Reply via email to