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

How does form processing work between GET and POST?

If a form uses either GET and POST is it possible to pass the data via the URL? Or better put, regardless of the method the form uses can the data be passed as a url for processing (such as http://www.test.com/cgi-bin/form.cgi?name=sdfsfsf&email=asdasda@adsada.com). Or can you do that for only one of GET or POST?

If you can't do it when the form method is POST, can WWW::Mechanize still push data to the form so long as all the required fields from the form processor are included?

Replies are listed 'Best First'.
Re: Forms POST and GET
by zentara (Cardinal) on Aug 30, 2011 at 16:27 UTC
    If I understand your question, you can use $cgi->Vars(); to get data regardless if its a get or post. This example takes cgi input and concats them into a string for relaying elsewhere.
    my $relay; my $cgi = new CGI; my %input= $cgi->Vars(); foreach $name (keys %input){ $value = $input{$name}; $relay .= "$name=$value&"; } $relay .= "Ecom_transaction_complete=$test&"; $relay .= "IOC_response_code=0&"; open (RT,">test/respgen.test"); print RT $relay; close RT; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new (POST => "$secure_server_address$cgi_dire +ctory/boacc.pl"); $req->content_type('application/x-www-form-urlencoded'); $req->content("$relay"); my $res = $ua->request($req); print $res->as_string;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Forms POST and GET
by Anonymous Monk on Aug 31, 2011 at 03:25 UTC