Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Strange CGI problem with POST

by r.joseph (Hermit)
on Mar 19, 2001 at 11:06 UTC ( #65376=perlquestion: print w/ replies, xml ) Need Help??
r.joseph has asked for the wisdom of the Perl Monks concerning the following question:

I know that this is probably a extremely simple thing that I am overlooking, and that I will most likely get --'ed for it, but here goes:

I am using for (obviously) CGI and I have a script which needs to use the POST method to send data because it is a large amount of data and I don't want it in the url.

I use the CGI::ReadParse() method to parse the incoming data because I used CGI-lib for a long time prior to and am more used to it. However, everytime I have tried to use POST instead of GET with and the above mentioned method, none of the values are placed in the %in array! What is going on!!

Thanks for the help, it is grately appreciated!

Violence is a last resort of the incompetant - Salvor Hardin, Foundation by Issac Asimov

Comment on Strange CGI problem with POST
Select or Download Code
Re: Strange CGI problem with POST
by sachmet (Scribe) on Mar 19, 2001 at 11:37 UTC
    Instead of using ReadParse, creating a new CGI object and then calling $cgi->param("field") is going to behave better. ReadParse is intended for backwards compatibility, and as long as you're doing new coding on the script anyway, it just seems like a better solution.
Re: Strange CGI problem with POST
by snowcrash (Friar) on Mar 19, 2001 at 14:00 UTC
    i never used the CGI::ReadParse() method, so i gave it a try. testing with the following minimal script it works fine - i.e. $in{antique} is set to the correct value using POST.

    maybe your problem is hidden somewhere else in your code, be sure to enable warnings and use strict;

    consider using cgi's new method's, when writing new code.
    #!/usr/bin/perl -w use strict; $|=1; use CGI; my $q = new CGI; use vars qw(%in); CGI::ReadParse(); print $q->header(), $q->start_html(), "The value of the antique is $in{antique}.\n", $q->start_form(), $q->textfield(-name=>'antique'), $q->end_form(), $q->end_html();

    snowcrash //////
Re: Strange CGI problem with POST
by r.joseph (Hermit) on Mar 19, 2001 at 21:52 UTC
    Thanks alot guys. I already had -w and use strict;, so I am going to have to dig into my code a little bit more. But you defintely have a point - I need to convert PDQ.

    However, just really quickly, I have a question for clairification: when using the my $cgi = CGI::new(); method, varibles can be accessed by using $cgi->param(...);, correct?

    Also, what would be the best way to go about converting programs that maybe be in excess of 1,000 lines to using the above stated method?

    Thanks for all the help!!

    R.Joseph's ReadParse is fine. Don't fix what isn't broke. Update them as you are forced to revisit them.

      Also, you don't have to use the Object Method system with CGI if you don't wish to. use CGI qw(:standard); will let you call most of the CGI methods as direct subroutines. $username= param('username'); is nice.

      $you = new YOU;
      honk() if $you->love(perl)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://65376]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2014-07-12 01:19 GMT
Find Nodes?
    Voting Booth?

    When choosing user names for websites, I prefer to use:

    Results (238 votes), past polls