Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How do post to a URL from a form and display the results in a browser?

by icuc (Initiate)
on Sep 13, 2000 at 07:15 UTC ( [id://32240]=note: print w/replies, xml ) Need Help??


in reply to How do post to a URL from a form and display the results in a browser?

I think this , perhaps , could satisfy your need.
---------------------------

#!/user/local/bin/perl

use strict;
use CGI;
use HTTP::Request;
use LWP::UserAgent;

my $q = CGI->new();
$q->use_named_paramters(1);
my $var1 = $q->param('a');
my $var2 = $q->param('b');

my $ua = LWP::UserAgent->new();

my $method = "POST";
my $url = "http://where_you_want";

use HTTP::Header;
my $header = HTTP::Header->new();
my $content = "v1=".$var1."&v2=".$var2;
my $request = HTTP::Request->new($method, $url, $header, $content);

use HTTP::Response;
my $response = $ua->request($request);
if($response->is_success) {
print $response->content;
}
else {
print $response->error_as_HTML;
}
-------------------------------------
for more details, please check Perl's Documents HTTP::Request, HTTP::Header, HTTP::Response, LWP::UserAgent, etc.
  • Comment on Re: How do post to a URL from a form and display the results in a browser?

Replies are listed 'Best First'.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://32240]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-20 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found