Nihil Angst has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I'm a newbie at Perl and I'm delighted
to find a Web site like this one.

I'm trying to use information gathered from
a form to generate personalized Web pages.
When I submit the form, rather than being taken
to the page-generating script, my browser displays
the code for the script that's supposed to process
the form data. When I try to access the page-
generating script from within File Manager,
I get an error message: "Your script produced
this error: (Maybe you didn't strip carriage
returns after a network transfer?)" . I've
looked at my uploaded code and I don't
see any added carriage returns.

Here's the code for the form and the page-
generating script. since my site is on Tripod, I
don't need #!/usr/local/bin/perl in the first
line. First, the form:

<FORM METHOD="get" ACTION="cgi-bin/TripodCGI.pm"> First Name: <INPUT TYPE="text" NAME="firstName" SIZE="25"><BR> Last Name:<INPUT TYPE="text" NAME="lastName" SIZE="25"><BR> Age: <INPUT TYPE="int" NAME="Age" SIZE="3"><BR> <INPUT TYPE="hidden" NAME="end_display" VALUE="cgi-bin/HTML.cgi"> <INPUT TYPE="submit"> <INPUT TYPE="reset"><BR> </FORM>

And here's the code for the page-generating script:

require TripodCGI.pm; $CGI = new TripodCGI.pm; $firstName = $CGI->param('firstName'); $lastName = $CGI->param('lastName'); $Age = $CGI->param('Age'); print "Content-type: text/html\n\n"; print <<ENDHTML; <HTML> <HEAD> <TITLE>CGI Test</TITLE> </HEAD> <BODY> <P>Greeings, $firstName, we're glad to see you. Members of the $lastName family are always welcome here. It's hard to believe that you're already $Age years old! How time flies.</P> </BODY></HTML> ENDHTML

Replies are listed 'Best First'.
Re: Form submit jumps to wrong file.
by chromatic (Archbishop) on Aug 06, 2002 at 23:13 UTC

    Your form action is set to the module, when it should probably be set to the program. I'm not aware that the type attribute of an input tag can be set to "int". I'd be surprised if your script compiled, as perl automatically adds the '.pm' to a module name for you, and it's quite likely not a part of the package name. (Though you claim otherwise, I'd still add the hash-bang line at the top of the script to give the web server some clue as to how to run it. Configurations vary.)

      Thanks for your help. The siutuation seems to have
      improved a little bit. Removing the ".pm" extension
      resulted in my jumping to a Tripod default page that
      said the URL I was trying to access does not exist.
      I've tried submitting the corrected form using
      both "post" and "get" methods; I get the same result
      either way.

      And regarding the hash-bang line, the host themself says
      not to use it. I've tried including it anyway,
      but it hasn't made a difference. Once more, thanks for
      your help.

        It sounds as though you're going to need to contact tripod to see exactly how they call a cgi script. Different hosts have different ways of calling them. They should be able to help you with that.

        That said, make sure your permissions are set correctly (755) or you'll find you're downloading the script, not running it - at least that was my first experience. :)

        Good luck!

        Some people fall from grace. I prefer a running start...