i have a form, which upon submission needs to refresh the page with a new url.
the new url however needs to come from the output of a curl function.
at the moment, I can get the curl function to operate correctly, but instead of refreshing the page with that url, it is just printing the url on the page.
have you any idea how i could use that url to refresh the page with?
thanks in advance
EDIT:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://uk.ImpulsePay.com/payforit?RouteID=5432&URL=Y");
curl_setopt($ch, CURLOPT_HEADER, 0);
header( "Location: curl_exec($ch)");
curl_close($ch);
If you visit the link above – it will display a page which has a link in the body. I am assentially trying to get the link in the body of the page, and then refresh the page to that page.
Does that make sense?
You’ll want to use the PHP header() method, see this page: http://php.net/manual/en/function.header.php
Here’s their example:
Take note of the line that reads:
If you need to change the header after some content has already been “printed” you’ll need to use output buffering, see this page to get started: http://php.net/manual/en/function.ob-start.php
UPDATE:
Your curl_exec( $ch ) is not executing because you can’t execute functionality inside of double quotes, you can only insert variables.
Here’s what you want to do:
Assuming that the response is just a URL, this will redirect your user’s browser to the value returned by your curl request.
UPDATE:
I missed that you do not have a return transfer setting.
You will need to add this line after your
CURLOPT_HEADERline:This will tell curl_exec to return the response instead of a boolean success indication.
See the “Return values” section at: http://php.net/manual/en/function.curl-exec.php