- 论坛徽章:
- 0
|
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Thin;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Entities;
my $out_dir="/tmp"; #我不知道这里该用什么??windows下不是用\作分 # 隔符的吗?
sub debug()
{
print "<H1>;DEBUG INFORMATION</H1>;\n";
print "<H2>;Form INformation</H2>;\n";
my %form_info=Parse_CGI();
foreach my $cur_key ( sort keys %form_info)
{
print "
;";
if (ref $form_info{$cur_key})
{
foreach my $value (@{$form_info{$cur_key}})
{
print encode_entities($cur_key),"=",
encode_entities($value),"\n";
}
} else
{
print encode_entities($cur_key),"=",
encode_entities($form_info{$cur_key}),"\n";
}
}
print "<H2>;Enviroment</H2>;\n";
foreach my $cur_key ( sort keys %ENV)
{
print "
;";
print encode_entities($cur_key),"=",
encode_entities($ENV{$cur_key}),"\n";
}
}
sub write_report()
{
my %form_info=Parse_CGI();
my $time=time();
open OUT_FILE,">;$out_dir/form.$time" or
die "could not open $out_dir/form.$time";
print OUT_FILE "Name form_info{name}
Group: $form_info{group}\n";
if ($form_info{work})
{
print OUT_FILE "Full Time Employee\n";
}
if ($form_info{intern})
{
print OUT_FILE " art of the Intern program\n";
}
if (not defined ($form_info{schedule}))
{
print OUT_FILE "***Did not select a schedule\n";
} else {
print OUT_FILE "Schedule form_info{schedule}\n";
}
print OUT_FILE "Comments:\n";
print OUT_FILE "$form_info{comments}\n";
close OUT_FILE ;
}
print "Content-type:text/html\n\n";
debug();
write_report();
print <<EOF;
<H1>;Thanks</H1>;
<p>;
Thank you for your time.
EOF
我用OptiPerl4.3它给出的提示是:
OptiPerl Server Warning
This script does not output it's mime type. It does not print something like:
print "Content-type: text/html\n\n";
The way this script output's it's header will not work on a real server! Here is the complete header:
[Sun Jun 5 21:13:21 2005] survey.pl: could not open /tmp/form.1117977201 at D:\Program Files\OptiPerl\Webroot\cgi-bin\survey.pl line 45.
Content-type:text/html
可是我看了后,还是不明白,求高手指点.
这是那个网页:
<head>;
<title>;Survey</title>;
</head>;
<body>;
<center>;<h1> lease fill in our survey</h1>;</center>;
<form action="/cgi-bin/survey.pl" method="post">;
<p>;
Name:
<input type="text" NAME="name" size=30>;
;
Group:
<Select NAME="group" Size=1>;
<option>;Software</option>;
<option>;Marketing</option>;
<option>;Support</option>;
</select>;
;
<input type="checkbox" name="work" value="1" checked>;
Full time employee
</input>;
;
<input type="checkbox" name="intern" value="1">;
Current a member of an intern program
</input>;
;
<p>;
I believe that my current project will be completed:
;
<INPUT type="radio" name="schedule" value="early">;
Early
</input>;
<input type="radio" name="schedule" value="ontime">;
On time
</input>;
<p>;
comments:
;
<textarea name="comments" cols=35 rows=4>;
Replace this with your comments.
</textarea>;
<input type="hidden" name="version" value="1.0">;
;
<input type="submit" value="Submit Form">;
</form>;
</body>;
</html>; |
|