views:

64

answers:

2

I'm trying to post XML data from a PHP page to another (not necessarily PHP-based) one without a form post. Is it possible to say do a POST via the header() function? If so, how?

+1  A: 

If client A starts script B, and you want script B to make a POST request to script C, then you need to make script B communicate to script C. This cannot be done using Header(), because it communicates from B to A.

Instead, you need to open a TCP connection to the webserver of script C, and then send the HTTP POST header in that direction. You can use fsockopen to create the connection, and then just send the headers using fwrite().

Lars D
Thanks for the explanation Lars. I think I'm going to go with the cURL solution as it seems a little more straightforward.
freakwincy
+2  A: 

I recommend using cURL to forward the request. There are lots of examples to help you along on the linked page.

Kaivosukeltaja