Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I'm running the following code, it's not working how I want.

HTML Form:
<html> <head> <title>Test</title> </head> <body> <form action="cgitest.pl" method="POST" enctype="application/x-www-for +m-urlencoded"> <input type="text" id="txtInput"> <br> <input type="submit" id="submit" value="submit"> </form> </body> </html>

Perl script:
#!/usr/bin/perl use strict; use warnings; use CGI qw(:standard); my $cgi = CGI->new; my $txtInput = $cgi->param('txtInput'); warn $txtInput; print $cgi->header(); print $cgi->start_html('Testing'); print $cgi->h1($txtInput); print $cgi->end_html;

Apache error_log
[error] [client XX.XX.XX.XX] Use of uninitialized value in warn at cgi +test.pl line 9., referer: http://server/form.html [error] [client XX.XX.XX.XX] Warning: something's wrong at cgitest.pl +line 9., referer: http://server/form.html

How can I deal with getting form input, so that it's not posted on the query string?

Replies are listed 'Best First'.
Re: Get HTML for values using CGI module
by Corion (Patriarch) on Feb 21, 2010 at 18:54 UTC

    While you gave your form element an id attribute, you didn't give it a name attribute, and hence it comes as a value without a name. Give it a name="txtInput" attribute and you'll find that your Perl code will work.

    Personally, I use Wireshark or the Firefox Live HTTP Headers Extension to inspect what actually gets sent to the server to check on which side the error lies.