我已经编写了一个cgi脚本,它执行以下操作:
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:cgi-lib :standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $q = new CGI;
print $q->header;
print "<center>";
print $q->h1('Let\'s do something!');
print "</center>";
print $q->start_html(-title => 'Do something');
print $q->end_form;
our %in;
&ReadParse(%in);
my @keys = keys %in;
my @values = values %in;
main();
sub main{
print "<center>";
my $q0 = new CGI;
print $q0->start_form(
-name => 'sniff_button',
-method => 'POST',
-enctype => &CGI::URL_ENCODED,
);
print $q0->submit(
-name => 'button',
-value => 'Do something',
);
print $q0->end_form;
print "</center>";
}
我想要做的是手动添加一些参数,因为下一个参数取决于之前的状态,而不仅仅取决于当前状态(所以我必须传递一个参数两次。)。
我用param()和URI完成了一些工作,但没有一个工作。有什么建议吗?
答案 0 :(得分:1)
隐藏字段就是答案:
sub main{
print "<center>";
my $q0 = new CGI;
print $q0->start_form(
-name => 'sniff_button',
-method => 'POST',
-enctype => &CGI::URL_ENCODED,
);
print $q0->hidden(
-name => 'machine_state',
-default => 'some_previous_value');
print $q0->submit(
-name => 'button',
-value => 'Do something',
);
print $q0->end_form;
print "</center>";
}