This is probably an easy question but I can't find the answer... I have a PHP script named 'send.php' which makes a cURL request to open an external web page. It outputs the external page to the browser. All completely by the books.
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);
All it does is posts some POST data to a processing script on an external site and then displays on the browser whatever that external script would display normally; ie, a confirmation message, thank you, etc.
Problem is: My 'send.php' is still the url that appears up in the navigation bar. So if I click around on that page, and the links are using relative paths, it tries to append my current path with those relative paths, which of course leads to a 404. Additionally, if there are more form fields on the page, and the action path is an empty string, it will try to post those submissions to send.php again on my server, which then generates errors.
How can I make it so it will still send the post data and output the result of the processing script but still allow the user to navigate the output page as they normally would? Or if it's a multi-page form, they can continue filling out page 2 as if they were just on that site?
Thanks in advance
Update: Solved by adding these lines to the above code:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$response = str_ireplace('<head>', "<head><base href=\"$url\" />", $response);
echo $response;