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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.