#!/usr/bin/perl
#script to take the values from the form
print "Content-type: text/html\n\n";
&read;
open("f1",">>comment");
select(f1);$|=1;
print $Hash{'comment'},"\n";
print " by: ",$Hash{'name'},"\n";
print "\n";
close(f1);
select(STDOUT);$|=1;
print "<title> The form response</title>";
print "<body bgcolor= \"fffff9\" >";
print "Here are the comments<p>";
open("f1","comment");
while($line=<f1>){
print "<pre>",$line,"<p>";}
print "<p></ul><hr>";
###printing the environment variable i use it only
for to know but they have no need in program#
# so i just comment them
###
#print "Here are the environment variables:<ul>";
#foreach $key (keys %ENV) {
#print "<li>$key: $ENV{$key}";
#}
print "</ul></body>";
sub read {
local ($i,$key,$val);
if($ENV{'REQUEST_METHOD'} eq "POST"){
read(STDIN,$Hash,$ENV{'CONTENT_LENGTH'});
}
@Hash = split(/&/,$Hash);
#$i=0;
foreach $i (0 .. $#Hash){
$Hash[$i] =~ s/\+/ /g;
($key,$val) = split(/=/,$Hash[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$Hash{$key} .= "\0" if (defined($Hash{$key}));
$Hash{$key} .= $val;
}
return length($Hash);
}
Note
be carefull about
the permissions of the file in which you put the comments.It should be
writetable by the others.