传递隐藏的文本值Perl CGI

时间:2018-12-12 18:01:33

标签: perl post dynamic cgi

我目前正在从事一个项目,我必须在课堂上进入数据库并对其执行一些操作。一种动作是编辑课程。在我的编辑页面中,我用一个编辑按钮填充一个表,其中包含数据库中的所有类,然后将有关该行的信息传递给新的.pl文件。在此文件中,我试图读取传递给我的那些隐藏值,以使用这些值预填充一些文本框以进行更新。但是我无法将隐藏的内容传递到我的新文件中。

print "<form action=http://localhost/cgi-bin/editing.pl method = 'post' >";
my $classid = $row[0];
my $classname = $row[1];
my $dep = $row[2];
my $classnum = $row[3];
my $grade = $row[4];
my $credit = $row[5];
print "<input type='hidden' name='classid' value='$classid' />" ;
print "<input type='hidden' name='classname' value='$classname' />" ;
print "<input type='hidden' name='dep' value='$dep' />" ;
print "<input type='hidden' name='classnum' value='$classnum' />" ;
print "<input type='hidden' name='grade' value='$grade' />" ;
print "<input type='hidden' name='credit' value='$credit' />" ;
print "<input type = 'submit' name = 'submit' value = 'Edit'>";
print "</form>";
print "</td>";
print "</tr>";

在这里,我用值动态填充表,然后使用编辑按钮链接到edit.pl页面。在那里,我正在尝试通过此操作获取信息

#Get the information the user entered
my $id = param('classid');
my $className = param('classname');
my $department = param('dep');
my $classnum = param('classnum');
my $grade = param('grade');
my $credits = param('credit');

print "$id , $className, $department , $classnum, $grade, $credits";#Get the information the user entered

但是我得到的唯一输出是“,,,,”,因此不会传输这些值。我不确定是什么问题。

编辑这里是我的表输出。忽略空行,我在实验时在数据库中有一束束。 enter image description here

FIX:在输入表单之前必须设置我的变量。

0 个答案:

没有答案