Simple Way to Relay or Pass POST Data From A Page to Another Without .htaccess, Even Cross-Domain

Tue, Aug 25, 2009

Programming & Code


So I had a page which I absolutely could not change or rename. The challenge was, this page would normally receive POST data, and I had to pass or relay this POST data to another page, which resided on another domain. I tried .htaccess, but that didn’t work, so I figured that I had to do some programming. It was simple enough with the curl library to do so, and here it is – The method to pass POST data from page to page:

$todo = "";

while (list($name, $value) = each($HTTP_POST_VARS)) {
$todo.=$name."=".$value."&";
}

$ch = curl_init('http://path.to/your/filename.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $todo);
curl_exec ($ch);
curl_close ($ch);
?>

Done!

Similar Posts:

Tags: , , , , , , , , ,
, , , , , , , , ,

This post was written by:

- Alvin is a Singaporean who's interested in marketing, techy stuff and likes to just figure out how the two can work with each other. On top of his blog, you can also follow him on Twitter.

Get Alvin's Report On How To Blog Successfully - Free!

Leave a Reply

*