简体   繁体   English

Perl HTML CGI网页错误

[英]Perl HTML CGI web page error

This is my perl code for a registration web page. 这是我用于注册网页的perl代码。 It should append values to a csv page. 它应将值附加到csv页。 It compiles perfectly but when I conncet it to my HTML program the web pae actually displays an error. 它可以完美编译,但是当我将其连接到HTML程序时,Web Pae实际上会显示错误。 This is the page http://cs.mcgill.ca/~zviran1/register.html HELP 这是http://cs.mcgill.ca/~zviran1/register.html帮助页面

#!/usr/loca/bin/perl
use CGI;
my $q = CGI->new();
use strict;

my $username = $q->param('username');
my $name = $q->param('name');
my $password = $q->param('password');
my @array = ($name, $username, $password, "\r");
my $line = join(' , ', @array);

print "Content-type: text/html \n\n";
my $file = 'Members.csv';
open (FILE, '+>>$file') or die "Cannot open file";
my $inputLine = <FILE>;
while($inputLine = <FILE>)
{
if(index($line, $username) != 4){
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE> Error Page </TITLE> \n";
print "</HEAD>\n";
print "<BODY>\n";
print "The username you have entered is already in use.";
print "<br><a href=\"index.html\">Home Page</a> \n";
print "<br><a href=\"register.html\">Registration Page</a> \n";
print "</BODY>\n";
close(FILE);
}
else {
#seeking to the end of the file to append
seek(FILE, 0, 2);
print FILE $line;
}
}
close(FILE);

Are you sure your Perl interpreter is where you want it to be? 您确定您的Perl解释器在您想要的位置吗? Your shebang line is 你的shebang专线是

#!/usr/loca/bin/perl

which is probably missing an 'l'. 可能缺少“ l”。 When you run the script locally via perl myscript.pl it ignores that line but when you run it under a webserver like Apache, it's actually used to find the Perl interpreter. 当您通过perl myscript.pl在本地运行脚本时,它将忽略该行,但是当您在诸如Apache之类的网络服务器下运行该脚本时,它实际上是用来查找Perl解释器的。

Other than that, have a look at your web server log (you should be able to access the error log even on simple hosting providers) because the error page your browser gets is merely the web server saying 'Hey, something went wrong there'. 除此之外,请查看您的Web服务器日志(即使在简单的托管提供程序上,您也应该能够访问错误日志),因为您的浏览器得到的错误页面仅仅是Web服务器说“嘿,那里出了点问题”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM