in reply to Problem with accessing POST data through Apache::Request

I would switch from using the new() class method to the instance() class method:

 my $apr= Apache::Request->instance(shift);

See:

instance()

See, also, Randy Kobes' article on mod_perl:

Accessing HTML Form Fields

Replies are listed 'Best First'.
Re^2: Problem with accessing POST data through Apache::Request
by derby (Abbot) on Aug 14, 2006 at 12:17 UTC

    I think instance is a decent fix but it is necessary because of the mixing of Apache::Request and CGI. Any interesting test would be to swap the these two lines:

    my $page = new CGI; my $test=$apr->param('school');
    If you put the $apr->param request before CGI, then it should work (since CGI would not have had the chance to consume the POST). But ideally, I wouldn't mix Apache::Request with CGI.

    -derby
      Thanks for the input, Derby. Putting the $apr->param request before CGI was a great idea!
Re^2: Problem with accessing POST data through Apache::Request
by thil (Sexton) on Aug 14, 2006 at 12:36 UTC

    Thanks.
    I tried with ,
    my $apr= Apache::Request->instance(shift);
    but no luck!

    But if I send the Post data along with the URL, it works fine. Even with Apache::Request->new(shift)
    ( i.e http://myhost/perl/test.pl?school=test )
    Can a configuaration issue cause this type of an errornuos situation? Here is my Apache mod_perl configuration for your information.

    Alias /perl/ /usr/local/apache/cgi-bin/ PerlModule Apache::Registry <Location /perl/> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI PerlSendHeader On allow from all </Location>

      Can a configuaration issue cause this type of an errornuos situation? Here is my Apache mod_perl configuration for your information.

      Probably not ... I think your issue is mixing CGI with Apache::Request. You new CGI is consuming the post before Apache::Request can read it. I would suggest using either CGI or Apache::Request but not both. If you want to use both, place the new CGI after all your $apr->param calls.

      And ... send the Post data along with the URL ... it's no longer POST data when you do that ... that makes it GET data

      -derby

        Thanks a lot for all your responses. It worked. :)

        It was the Apache::Request - CGI mix which gave me troubles.