RE: [PHP-DB] How to forward a POSTed form to another server and catch the return for further processing
| From: | Peter Lovatt | Date: | Sun, 15 Aug 2004 07:44:56 +0000 |
| Subject: | RE: [PHP-DB] How to forward a POSTed form to another server and catch the return for further processing | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35717@lists.php.net to get a copy of this message | ||
hi
this should do the trick
Peter
// this is the script to pass the post onto
$server_to_post_to = 'http://www.test.com/somescript.php';
$url = parse_url($server_to_post_to);
unset($request_data) ;
//run through the data POSTed to this server and build a new POST request
foreach ($_POST as $name => $value)
{
if (strlen($request_data) > 0) $request_data .= '&';
$request_data .= $name.'='.urlencode($value);
}
//create a new post to the other sever
$request = "POST ".$url['path']." HTTP/1.1\r\n".
"Host: ".$url['host']."\r\n".
"Content-type: application/x-www-form-urlencoded\r\n".
"Content-length: ".strlen($request_data)."\r\n\r\n".
$request_data;
// Open the connection
$fp = fsockopen($url['host'], 80, $err_num, $err_msg, 30);
if ($fp)
{
// Submit form
fputs($fp, $request);
// Get the response
while (!feof($fp))
{
$response .= fgets($fp,1024);
}
fclose($fp);
//do somthing with $response here
}
else
{
//could not connect to server
print 'Error '.$err_num.' '.$err_msg;
}
> -----Original Message-----
> From: Yanglong Zhu [mailto:yanglong@yahoo.com]
> Sent: 15 August 2004 01:41
> To: php-db@lists.php.net
> Subject: [PHP-DB] How to forward a POSTed form to another server and
> catch the return for further processing
>
>
> 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.
>
> Thanks for your help.
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>