
Larkdog
User
Aug 31, 2004, 5:05 AM
Post #3 of 12
(1133 views)
|
Well, I guess it's caused by a bug in your code. But it's hard to give any more details without seeing the code. here you go: #!/usr/bin/perl print "Content-type:text/html\n\n"; $|++; use CGI::Carp qw(fatalsToBrowser); # Relative path of Guestbook.html $guestbook_file = '../html/guestbook/guestbook.html'; @month = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); if($ENV{'REQUEST_METHOD'} eq "POST"){ $data_length = $ENV{'CONTENT_LENGTH'}; $bytes_read = read(STDIN, $my_data, $data_length); } @name_value_array = split(/&/, $my_data); foreach $name_value_pair (@name_value_array) { ($name, $value) = split(/=/, $name_value_pair); $name =~ tr/+/ /; $value =~ tr/+/ /; $name =~ s/%(..)/pack("C",hex($1))/eg; $value =~ s/%(..)/pack("C",hex($1))/eg; if($form_data{$name}) { $form_data{$name} .= "\t$value"; } else { $form_data{$name} = $value; } } ($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek, $DayOfYear, $IsDST) = localtime(time); $Year = $ShortYear + 1900; $EntryDate = "$month[$Month] $DayInMonth, $Year"; open(GUESTBOOK, "<$guestbook_file") || die "Can't open GUESTBOOK: $guestbook_file\n"; @guestbook =<GUESTBOOK>; close(GUESTBOOK); open(GUESTBOOK, ">$guestbook_file") || die "Can't open GUESTBOOK: $guestbook_file\n"; foreach $line (@guestbook){ if($line =~ /<!--My Latest Guest:-->/i) { print GUESTBOOK "<!--My Latest Guest:-->\n"; print GUESTBOOK "<DL>\n"; if($form_data{'email'}) { print GUESTBOOK "<DD><I><B><A HREF=\"mailto:$form_data{'email'}\"> $form_data{'name'}</A></B></I>\n"; } else { print GUESTBOOK "<DD><B>From : </B><I> $form_data{'name'}</I>\n"; } print GUESTBOOK "<DD><B>Period: </B><I>$form_data{'period'}</I>\n"; print GUESTBOOK "<DD><B>Homepage:</B><I><A HREF=\"$form_data{'web'}\">$form_data{'web'}</A></I>\n"; print GUESTBOOK "<P>\n"; print GUESTBOOK "$form_data{'comments'}\n"; print GUESTBOOK "</P>\n"; print GUESTBOOK "<p><I><font size=2>\n"; print GUESTBOOK "signed on $EntryDate\n"; print GUESTBOOK "</font></I>\n"; print GUESTBOOK "</DL>\n"; print GUESTBOOK "<HR color=blue size=3>\n"; } else { print GUESTBOOK "$line"; } } close(GUESTBOOK); open (MAIL, "|sendmail -t"); print MAIL "To: $form_data{'name'}<$form_data{'email'}>\n"; print MAIL "From: Mr. Larkins <mrlarkins\@mrlarkins.com>\n"; print MAIL "Thank you $form_data{'name'} for signing my guestbook. You should be able to view it immediately.\n"; print MAIL "You submitted the following information to www.MrLarkins.com.\n"; print MAIL " \n"; print MAIL "Name: $form_data{'name'}\n"; print MAIL "Email Address: $form_data{'email'}\n"; print MAIL "Web Address: $form_data{'web'}\n"; print MAIL "Class Period: $form_data{'period'}\n"; print MAIL "Comments:\n"; print MAIL "$form_data{'comments'}\n"; print MAIL " \n"; print MAIL "Thanks.\n"; print MAIL "Mr. Larkins\n"; close (MAIL); open (MAIL, "|sendmail -t"); print MAIL "To: Mr. Larkins <mrlarkins\@mrlarkins.com>\n"; print MAIL "From: $form_data{'name'}<$form_data{'email'}>\n"; print MAIL "Subject: I signed your guestbook\n\n"; print MAIL "$form_data{'name'} submitted the following entry to your guestbook.\n"; print MAIL " \n"; print MAIL "Name: $form_data{'name'}\n"; print MAIL "Email Address: $form_data{'email'}\n"; print MAIL "Web Address: $form_data{'web'}\n"; print MAIL "Class Period: $form_data{'period'}\n"; print MAIL "Comments:\n"; print MAIL "$form_data{'comments'}\n"; close (MAIL); print <<"EOF" <HTML><TITLE>Entry Submitted</TITLE><HEAD> <META HTTP-EQUIV="refresh" content="4;URL=../guestbook/guestbook.html"></HEAD><BODY> <H1>Your GuestBook Entry has been Submitted\!</H1> Your guestbook entry has been successfully added to the guestbook and in <font size=24>3</font> seconds you will be taken back to view it. </BODY> EOF #=========================== it would also be helpful if you guided me in convert this old style into one that uses 'param' feature www.MrLarkins.com
(This post was edited by Larkdog on Aug 31, 2004, 5:12 AM)
|