#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print header;
print start_html("Thank You");
print h2("Thank You");
my %form;
foreach my $p (param()) {
$form{$p} = param($p);
print "$p = $form{$p}<br>\n";
}
print end_html;
这适用于所有基本形式,确认很好但不在表http://www.quickpaysolutions.com/tt.html
中我有另一种形式可以使用表,但表单确认按字母顺序排列,而不是表单的构造方式。我希望表格边框中的表格和表格的顺序。
http://www.quickpaysolutions.com/jt.html
代码:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use CGI;
my $cgi = new CGI;
print
$cgi->header() .
$cgi->start_html( -title => 'Form Results') .
$cgi->center($cgi->h1('Your Reciept <br> Please Print this Reciept')). "\n";
my @params = $cgi->param();
print '<table border="1" width="500" align="center" cellspacing="1" cellpadding="2">' . "\n";
foreach my $parameter (sort @params) {
print "<tr><th>$parameter</th><td>" . $cgi->param($parameter) . "</td></tr>\n";
}
print "</table>\n";
#
$ENV{PATH} = "/usr/sbin";
open (MAIL, "|/usr/sbin/sendmail -oi -t ") or &dienice("Can't fork for sendmail: $!\n");
my $recipient = 'test@quickpaysolutions.com, test2@quickpaysolutions.com';
print MAIL "To: $recipient\n";
print MAIL "From: nobody\@quickpaysolutions.com\n";
print MAIL "Subject: Form Data\n\n";
foreach my $p (param()) {
print MAIL "$p = ", param($p), "\n";
}
close(MAIL);
# Now print a thank-you page
# The dienice subroutine handles errors.
sub dienice {
my ($errmsg) = @_;
print "<h2>Error</h2>\n";
print "<p>$errmsg</p>\n";
print end_html;
exit;
}
$cgi->end_html . "\n";
答案 0 :(得分:1)
表单确认按字母顺序排列,而不是表单的构建方式
那是因为你有
foreach my $parameter (sort @params) { ... }
如果删除sort
,则参数将以与第一个示例相同的顺序显示。
但是请理解一般来说CGI和特别是HTML生成功能应该被避免,特别是对于实际的网站,这似乎是。使用Dancer2