I am using the following code to send a POST request using cURL. This is working perfectly. The only issue I have is that the location in the address bar does not update itself.
The webpage that sends this request is http://www.somedomain.com/merge.php, but after the post has been executed the address bar still shows http://www.somedomain.com/merge.php instead of http://www.somedomain.com/preview.php
I have tried using curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); with no luck.
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'www.somedomain.com/preview.php');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, 'landscape=true');
curl_exec ($c);
curl_close ($c);
Thank you
You are misunderstanding what’s going on. There are three parties involved:
The client sends an HTTP request to your server, your server sends an HTTP request to somedomain.com. Your server will receive the response, the client has nothing to do with it. If you want to redirect the client, you need to issue an appropriate HTTP response to the client from your server telling it to redirect elsewhere. Because the client is talking to your server, not somedomain.com. Whatever is going on between your server and somedomain.com is none of its business.
If you want the client to directly send a POST request to somedomain.com, you need to create a form that POSTs to somedomain.com or trigger something equivalent using Javascript.