Reputation: 459
I have two php database apps on different servers. I would like to be able to transfer the data from a particular record from the first server to the second, with some processing inbetween to account for the differences in database schema. The two servers cannot access each others databases. So the user would click a link on the record and then basically that data would be transferred over to the other server for confirmation. I looked at a redirect with POST, but that doesn't seem to be possible. Any better ways?
Select record on server 1 -> Process record to correct form -> transfer PHP array to server 2 -> confirmation page on server 2
Upvotes: 0
Views: 753
Reputation: 2962
you can use curl as i mentioned with the help of this example
//assuming the variable that holds your record is $row
$row = array("key1" => "value1", "key2" => "value2");
$post_fields = "";
foreach($row as $key=>$field){
$post_fields .= $key . "=" . $field . "&";
}
$Curl_Session = curl_init('http://yourseconddomain.com/yourfile.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_exec ($Curl_Session);
curl_close ($Curl_Session);
Upvotes: 1
Reputation: 12525
If I had to do something like this, I'd take my data that needs to be processed, process it on my server (from where I take it) then serialize result and send it to another server using post method. Using another script unserialize and simply store in a database that runs on the second server.
Upvotes: 1