in reply to Re^2: making a difference between POST parameters and URL parameters
in thread making a difference between POST parameters and URL parameters

Hmmm ... I wonder if Doing both is more about CGI possibly processing *both* URL params and STDIN params for a POST? One of the best comments in cpan:

if ($meth eq 'POST') { $self->read_from_client(\$query_string,$content_length,0) if $content_length > 0; # Some people want to have their cake and eat it too! # Uncomment this line to have the contents of the query string # APPENDED to the POST data. # $query_string .= (length($query_string) ? '&' : '') . $ENV{'QUERY_ +STRING'} if defined $ENV{'QUERY_STRING'}; last METHOD; }
... I like cake.

-derby
  • Comment on Re^3: making a difference between POST parameters and URL parameters
  • Download Code

Replies are listed 'Best First'.
Re^4: making a difference between POST parameters and URL parameters
by roboticus (Chancellor) on Feb 14, 2008 at 22:03 UTC
    ...but doesn't Fletch keep telling us that the cake is a lie?

    ...roboticus

    /me has tongue firmly planted in cheek

Re^4: making a difference between POST parameters and URL parameters
by gfk (Novice) on Jan 28, 2010 at 14:46 UTC

    Well, if it's a POST query, param() will only get you POST params.

    You can get GET params by instancing another CGI object like this:

    my $get = CGI->new($ENV{'QUERY_STRING'});

    Example:

    use strict; use warnings "all"; use CGI; my $post= CGI->new; my $get = CGI->new($ENV{'QUERY_STRING'}); my $foo_from_post = $post->param('foo'); my $foo_from_get = $get->param('foo');

      Or you could RTFM and use the url_param() method of the existing object instead.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)