tags:

views:

36

answers:

2

Hi, I am currently using curl to fill an form, but after completion of the post, the other script which handles the form is redirecting to other url , now I want to get the url , for which the script is redirecting to a variable.

Thanks..

+3  A: 

You would use

curl_setopt($CURL, CURLOPT_HEADER, TRUE);

And parse the headers for the location header

RobertPitt
+1 missed that point :)
Sarfraz
No problem, using the post fields will send the data and then server would redirect and as the data is outputted as the responses, curl will pick that up so then the location header should be there.
RobertPitt
+1  A: 

You may want to set the CURLOPT_FOLLOWLOCATION to true.

Or set the CURLOPT_HEADER to true and then use regexp to get the Location header.

Delta
Also take note of php safe mode with this, http://www.php.net/manual/en/function.curl-setopt.php#95027
RobertPitt