用Perl制作留言本案例之二
發(fā)表時(shí)間:2024-02-08 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]將此表單的提交后的動(dòng)作交給guest-book.cgi程序。 guest-book.cgi #! perl print"Content-type:text/htmlnn"; read(STDIN,$buffer,$ENV{'CONTE...
將此表單的提交后的動(dòng)作交給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"請(qǐng)不要留空";
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"請(qǐng)觀看留言本";
exit(0);