FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Simulating a Form Method=Post submission in PHP
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Simulating a Form Method=Post submission in PHP [message #178435 is a reply to message #178421] Mon, 18 June 2012 07:54 Go to previous message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma:
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reading & Displaying Latex Rendered images
Next Topic: Apache and php to show http request headers.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 07:04:04 GMT 2024

Total time taken to generate the page: 0.05220 seconds