c_pattle Posted October 18, 2010 Share Posted October 18, 2010 I have just installed cURL and am learn to use it but I'm not sure exactly what I am doing. For example I have a page with this code on it. if($_GET['number'] == "6") { echo("<p>the number is six</p>"); } Then I am trying to use cURL to send the number 6 to this page so that it returns "the number is 6". However I am just getting an output of "1". Below is the code I am using to try to get the output of "the number is 6". $ch2 = curl_init(); curl_setopt($ch2,CURLOPT_URL,'http://localhost/crawler/crawlertest.php'); curl_setopt($ch2, CURLOPT_POST, 1); curl_setopt($ch2,CURLOPT_POSTFIELDS,'number=6'); $return = curl_exec($ch2); echo ($return); curl_close($ch2); Thanks for any help Link to comment https://forums.phpfreaks.com/topic/216187-curl-help/ Share on other sites More sharing options...
BlueSkyIS Posted October 18, 2010 Share Posted October 18, 2010 $return is the return value of the operation, not the returned content if any. curl_exec: Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure. You might only need to add this line before using curl_exec: curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); Link to comment https://forums.phpfreaks.com/topic/216187-curl-help/#findComment-1123579 Share on other sites More sharing options...
BlueSkyIS Posted October 18, 2010 Share Posted October 18, 2010 this looks like a good example of back-and-forth communication with curl: http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html#menu0-el0 Link to comment https://forums.phpfreaks.com/topic/216187-curl-help/#findComment-1123580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.