0

我有一个 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文件时,我仍然得到空值。

4

1 回答 1

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'>
于 2013-07-31T14:18:24.757 回答