Yanglong Zhu wrote:
How to forward a POSTed form to another server and catch the return for further processing.
I think I did this before. But now I have completely forgot how that was done. The posted form data is processed on the other server, the results should be returned or captured by the first server. Obviously my brain is not working.
You can use fopen() and contexts:
(mostly copied from php|architect, May 2004, www.phparch.com)
$data = ''; foreach($_POST as $key=>$value) { $data .= $key.'='.urlencode($value).'&'; }
$opts = array( 'http' => array( 'method' => 'POST', 'header' => "Content-Type: application/x-www-form-urlencoded\r\n" . 'Content-Length: '.strlen($data), 'content' => $data )); $context = stream_context_create($opts); $fp = fopen('http://localhost/post.php', 'r', false, $context);
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php