Phpcurl redirection: I just got started with curl. I want to use curl & nbsp; post information and redirect it to the target page (with the sent POST information redirected) & lt ;? Php $ url & nbsp; = & nbsp; "http: // localhost/opms/WebContent/test_output.php"; php curl redirection
You want to use the curl post information when you are new to curl and redirect it to the target page (with the sent POST information redirected)
$url = "http://localhost/opms/WebContent/test_output.php";
$post_data = array (
"foo" => "bar",
"query" => "Nettuts",
"action" => "Submit"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,true);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_MAXREDIRS,10);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$output = curl_exec($ch);
curl_close($ch);
I don't know whether to use things on the internet. I just wanted to change the address in the last address bar to test_output.php, but it was always unsuccessful.
Is it because curl cannot jump at all? I am still setting a question. please give me a great answer. thank you!
------ Solution --------------------
CURLOPT_FOLLOWLOCATION indicates:
When the target page jumps, that is, when the http header contains the Location command, the new target page is read.
If this attribute is not set, curl only reads one page.