我有一个html表,每行有2个单选按钮和一个保存按钮。我想在保存时存储单选按钮的值,并在重新访问页面时预设值。这是我写的html代码
<form action='table_extract.cgi' method = 'post'>
<td><input type='radio' name='signoff' value = 'approve'>Approve<br>
<input type='radio' name='signoff' value='review'>Review</td>
<td><input type='submit' name='button' value='Save'/></td></form>
这就是table_extract.cgi
中的内容#!usr/local/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use warnings;
print <<END;
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
END
my $regfile = 'signoff.out';
my $sign;
$sign = param('signoff');
open(REG,">>$regfile") or fail();
print REG "$sign\n";
close(REG);
print "param value :", param('signoff');
print <<END;
<title>Thank you!</title>
<h1>Thank you!</h1>
<p>signoff preference:$sign </p>
END
sub fail {
print "<title>Error</title>",
"<p>Error: cannot record your registration!</p>";
exit; }
我无法从html格式.cgi
脚本中传递参数。我在网上搜索,发现Apache服务器需要可见cgi脚本。我试图检查加载cgi是否在httpd.conf
上运行并将cgi脚本移动到cgi-bin
。它不起作用。当我尝试执行.cgi
文件时,我仍然得到空值。
答案 0 :(得分:0)
如果此脚本是可执行的,我将从检查权限开始:
chmod +x table_extract.cgi
另外请检查
中的日志文件/var/log/http/*
检查脚本是否运行时没有语法错误:
perl -c table_extract.cgi
如果您的HTML页面不在cgi-bin目录下,请考虑将表单操作参数修改为:
<form action='/cgi-bin/table_extract.cgi' method = 'post'>