[摘要]将此表单的提交后的动作交给guest-book.cgi程序。 guest-book.cgi #! perl print"Content-type:text/htmlnn"; read(STDIN,$buffer,$ENV{'CONTE...
将此表单的提交后的动作交给guest-book.cgi程序。
guest-book.cgi
#! perl
print"Content-type:text/htmlnn";
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair(@pairs){
($name,$value)=split(/=/,$pair);
$value=~tr/+//;
$value=~s/%([a-f A-F 0-9][a-f A-F 0-9])/pack("C",hex($1)
)/eg;
$FORM{$name}=$value;
}
print"";
print" 留言本";
foreach $check(values%FORM){
if($check eq""){
print"----------------------------------------------------------------";
print"请不要留空";
exit(0);
}
}
$FORM{'suggest'}=~s/cMn/n/g;
$filename="c:/website/htdocs/book.html";
open(FILE,">> $filename");
print FILE "名字:$FORM{'name'}n";
print FILE "Email:
print FILE "留言:$FORM{'suggest'}";
close{FILE};
print "谢谢留言";
print"请观看留言本";
exit(0);
……