Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6359

Re: Simulating a Form Method=Post submission in PHP

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: Simulating a Form Method=Post submission in PHP
Date Mon, 18 Jun 2012 09:54:01 +0200
Organization A noiseless patient Spider
Lines 37
Message-ID <4FDEDE99.2060903@arnowelzel.de> (permalink)
References <CC0247F5.270E7%hal9001@panix.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="uO9Sccelu4tfD+GMr79Efw"; logging-data="28701"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S13ZhoL5Zwcm3ut0A6trMsCV+15CyTKo="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
In-Reply-To <CC0247F5.270E7%hal9001@panix.com>
Cancel-Lock sha1:xRu/m2xyAji1A3Dmby77rS6uf5M=
Xref csiph.com comp.lang.php:6359

Show key headers only | View raw


Robert Rosenberg, 16.06.2012 20:25:

> I would like to go to an external site and send a form to it via Post
> (simulating having generated the form and having the user submit it). I know
> that if I had been using GET, I could just code the parms along with the URL
> in the location command. To simulate Post I assume that I just need to use
> header to send the POST parms but I do not know the format of what to place
> in the header request (and I assume that I then use location to fire off to
> connection).

If available - use curl:

<http://php.net/manual/en/book.curl.php>

> Can someone either supply me with a sample code to do this or give me the
> URL of the documentation of the Headers that get sent by Post so I can look
> them up and create the needed script myself.

<?php
$data = array(
	'field1'=>'value1',
	'field2'=>'value2'
	);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://server.example');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
?>


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Simulating a  Form Method=Post submission in PHP Robert Rosenberg <hal9001@panix.com> - 2012-06-16 14:25 -0400
  Re: Simulating a  Form Method=Post submission in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-16 14:45 -0400
  Re: Simulating a  Form Method=Post submission in PHP Luuk <luuk@invalid.lan> - 2012-06-16 20:46 +0200
    Re: Simulating a  Form Method=Post submission in PHP Robert Rosenberg <hal9001@panix.com> - 2012-06-16 20:10 -0400
      Re: Simulating a  Form Method=Post submission in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2012-06-16 20:41 -0400
        Re: Simulating a  Form Method=Post submission in PHP Luuk <luuk@invalid.lan> - 2012-06-17 20:14 +0200
      Re: Simulating a  Form Method=Post submission in PHP "J.O. Aho" <user@example.net> - 2012-06-17 14:19 +0200
      Re: Simulating a  Form Method=Post submission in PHP Denis McMahon <denismfmcmahon@gmail.com> - 2012-07-03 12:11 +0000
  Re: Simulating a  Form Method=Post submission in PHP Arno Welzel <usenet@arnowelzel.de> - 2012-06-18 09:54 +0200

csiph-web