Jump to content

how to post data from one url to another url


poojajoshi

Recommended Posts

Not quite sure what you are asking exactly.

 

If you want to redirect them, then

<?php
header('Location: http://www.example2.com');
die();

If you want to get the content from example2.com, then you have a couple of options.

 

Remote file open or cURL (if you have it installed) are the two the spring to mind.  Personally, I would use cURL:

<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.example2.com');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // If 0, curl_exec will print data
$content = curl_exec($curl);
?>

This can slow down your script quite a bit though...

Or, you can just set the target of the form (on Domain1) to point to the receiving page on Domain2.

 

Of course, if you are doing this to POST data to a site you don't control, they may have safefuards in place to prevent such POSTs. If so, curl() woudl be the answer.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.