Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PHP] How do I submit a POST form?

0 views
Skip to first unread message

Alexis Michel Golzman

unread,
Feb 25, 2001, 3:47:27 AM2/25/01
to
Hi,

I've submitted many times a GET form like this:

header("Location:
http://examplesite.com/myscript.php3?key=value&key2=value2&keyn=valuen");

but now I need to submit a POST form.

How is this done?

I found this Perl code on the web:
--------------------------------------------------------------
use strict;
use LWP::UserAgent; # libwww-perl

my $ua = new LWP::UserAgent or die "new UA: $!";
$ua->agent("testclient/1.0");

my $url = 'http://localhost/cgi-bin/test.pl';
my $request = new HTTP::Request('POST', $url) or
die "new HTTP::Request POST '$url': $!";
$request->content_type('application/x-www-form-urlencoded');

$request->content('field1=value1&field2=value2&field3=value3');

#$request->content('field1=value1'); # optional method
#$request->add_content('&field2=value2');
#$request->add_content('&field3=value3');

my $response = $ua->request($request);
print $response->content;
--------------------------------------------------------------

But I want to know if there is a way of doing it in PHP...

Thanks in advance for your help! :-)

Kind regards,
Alexis Golzman
mailto:ale...@trafficbar.com
http://trafficbar.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general...@lists.php.net
For additional commands, e-mail: php-gene...@lists.php.net
To contact the list administrators, e-mail: php-lis...@lists.php.net

0 new messages