Hi all,
What I want to do is this: when the user fetches a page from my server, a POST request should be sent to another server than the one my site is on. Like: call http://theotherserver.com/somescript.php with variable1=3 and variable2=fred. The data that is sent does not require user interaction, I send it with the page from my server. I want the data to be sent from the client, not from my server.
I'm not familliar with how HTTP requests are constructed and therefore my "invesigations" have lead to two thoughts that might be completely off target.
1. Include something like this:
<img src="http://theotherserver.com/somescript.php?variable1=3&variable2=fred" height="0" width="0" />
but I suspect that this won't produce a valid POST request (but rather a GET request?)
2. Using curl:
<?php $url = 'http://theotherserver.com/somescript.php'; $ch = curl_init();
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,2);
curl_setopt($ch,CURLOPT_POSTFIELDS,'variable1=3&variable2=fred');
$result = curl_exec($ch);
curl_close($ch); ?>
but I suspect this will send the request from my server, not from the client.
SO, do you have any ideas on how to solve it? (If it can even be done?)
Thankful for any response.
/Fredrik