Please help a PERL newbie

Discussion in 'Programming' started by moe374, Jan 13, 2009.

  1. #1
    Hello. I am a newb to PERL and programming in general.
    I am trying to make a small script for my website using perl. So far, no luck.

    I have a form with one field on a website. When someone submits the form, i have a line as follows:

    <FORM METHOD="post" ACTION="http://www.mysite.com/cgi/grp.cgi">

    My problem is this, when I submit the form, it redirects to http://www.mysite.com/cgi/grp.cgi where is says:
    and I get the following in the error log.


    I tried this is the script I tried:

    
    #!/usr/bin/perl
    use CGI qw(:standard);
    
    
    if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    	read(STDIN, $keywordsInput, $ENV{'CONTENT_LENGTH'});
    	@keywordArray = split(/"\n"/, $keywordsInput);
    
     	print "Content-type: text/html\n\n";
        	print "<HTML>\n";
        	print "<HEAD>\n";
        	print "<TITLE>Results</TITLE>\n";
        	print "</HEAD>\n";
        	print "<BODY BGCOLOR=#FFFFCC TEXT=#000000>\n";
        	print "<H1>Your Results</H1>\n";
        	print "\n";
        	print "<P>\n";
        	print "<H3>@keywordsArray<BR>\n";
        	print "<P>\n";
        	print "</BODY>\n";
        	print "</HTML>\n";
    
    
    }
    
    Code (markup):
    The line under the shebang line, im not sure if i need it, ive tried the script with and without this line. Ive also tried simply outputting some HTML when the form is submitted but I have the same problem.

    I changed permissions on both the cgi file and the folder it is contained in to 775.

    Help would be greatly appreciated. Thank you.
     
    moe374, Jan 13, 2009 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Try change the 'POST' to lower case in this line:
    if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    Code (markup):
    Also, move this line up (probably after the line with the 'use' statement), so that if you get any error the error message would be displayed properly on the browser.
    print "Content-type: text/html\n\n";
    Code (markup):
     
    phper, Jan 13, 2009 IP