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

Doing both is supported by CGI, but only because the CGI developers are kind to web developers, not because it's an actual part of the CGI standard.

Actually, both are in the standard. See here

update: misunderstood the quoted line. I was trying to say that both methods are in the standard, not the usage of both simultaneously.

  • Comment on Re^2: making a difference between POST parameters and URL parameters

Replies are listed 'Best First'.
Re^3: making a difference between POST parameters and URL parameters
by derby (Abbot) on Feb 14, 2008 at 16:40 UTC

    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
      ...but doesn't Fletch keep telling us that the cake is a lie?

      ...roboticus

      /me has tongue firmly planted in cheek

      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". ;-)