cgi文件对apache不可见,html表单返回空值



我有一个html表,每行有两个单选按钮和一个保存按钮。我想在保存时存储单选按钮的值,并在重新访问页面时预设值。这是我编写的的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 "$signn";
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脚本传递params。我在网上搜索,发现Apache服务器需要cgi脚本的可见性。我试图检查httpd.conf上的load-cgi函数,并将cgi脚本移动到cgi-bin。它不起作用。当我尝试执行.cgi文件时,仍然会得到null值。

如果这个脚本是可执行的,我会从检查权限开始:

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'>

最新更新