|
| |
CGI Scripts
|
Web Hosting Services |
post_message.plThis script parses the data entered on the form saves it to the message_board.txt file, reopens the file and displays the contents to the screen. Note: Some code added to parsing routine to remove illegal and unwanted characters from Query String. #!/usr/bin/perl#post_message.pl$buffer=$ENV{'QUERY_STRING'};$buffer =~ tr/+/ /;$buffer =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;$buffer =~ s/<!--(.|\n)*-->/ /g;$buffer =~ tr/\\|[|]|<|!|"|$|{|}|*|#|'|>|||;|%/ /; @pairs = split(/&/,$buffer);foreach $pair(@pairs){($key,$value)=split(/=/,$pair);$formdata{$key}.="$value";}$yourname=$formdata{'yourname'};$email=$formdata{'email'};$subject=$formdata{'subject'};$message=$formdata{'message'};open(INFO, ">>message_board.txt"); # Open for appendingprint INFO "$yourname|$email|$subject|$message\n";close (INFO);open(INFO, "message_board.txt"); # Open db for reading and display@array=<INFO>;close (INFO);print "Content-type:text/html\n\n"; #Follow with blank lineprint "<html>\n";print "<head><title>Message Board</title>\n";print "<style type="text/css">\n";print "h2\{font-family: Arial;font-style : normal ;font-size : 12pt; font-weight :bold;text-align :center\}\n";print "td\{font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal \}\n";print "p\{ font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal;text-align :left; width : 40em \}\n";print "</style>\n";print "</head>\n";print "<body>\n";print "<div align=\"center\">\n";print "<h2>Message Board</h2>\n";print "<table width=\"550\" cellpadding=\"5\" cellspacing=\"0\" border=\"1\">\n";foreach $line (@array){($yourname,$email,$subject,$message)=split(/\|/,$line);print "<tr><td>\n";print "Posted by: $yourname <a href="mailto:$email">Return Message by Email</a><br>\n";print "Subject:$subject<br>\n";print "<br>\n";print "Message:<br>\n";print "<p>$message</p>\n";print "</td></tr>\n";}print "</table>\n";print "<br><br>\n";print "<a href=\"./message_brd.html\">Post a New Message</a>\n";print "</div>\n";print "</body>\n";print "</html>\n"; |
Create a Website with CMS
|
| Net Success 2000 Plus Inc PO Box 1508 Somerset, KY 42502 Copyright 2000 - 2007 Net Success 2000 Plus Inc Last Modified: January 19, 2008 |