1

My CURL redirect is not working i am redirected to same page but the same page is empty when it is rendered after i submit it. Here is my code.

 $ch = curl_init("http://localhost/soft/entercode.php");
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'variable1=abc&variable2=123');
    $result = curl_exec($ch);
    curl_close($ch);
temp-learn
  • 527
  • 2
  • 9
  • 31

3 Answers3

1

look into the configurations cause this error is sometime caused by installed CURL check that if the installation files have all the required files for win 32 version of CURL.

noobie-php
  • 6,817
  • 15
  • 54
  • 101
  • yeah later i found that Curl installation with windows 32 bit had some issues i needed to download 2 library files. Now its working fine tho CURl is already installed as mentioned earlier needed to download 2 library files – temp-learn Nov 29 '11 at 10:32
  • @temp-learn: Could you please post the details of the files which you found missing ?(if you still remember). I am having the same problem and would be helped a lot. Thanks in advance – ankit Aug 25 '12 at 15:38
0

Try adding and changing:

curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

Hope it works for you

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
0
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://localhost/soft/entercode.php");    
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'variable1=abc&variable2=123');    
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_MAXREDIRS,1);
$buffer = curl_exec($ch);
curl_close($ch);

Check this it will work ..

Akhil Thayyil
  • 9,263
  • 6
  • 34
  • 48
  • thx for replying but it is not working. i am getting this 500 Internal Server Error - http://(myUrl);" – temp-learn Nov 28 '11 at 07:55
  • that may be because of some bad config of server – Akhil Thayyil Nov 28 '11 at 11:30
  • yeah later i found that Curl installation with windows 32 bit had some issues i needed to download 2 library files. Now its working fine tho CURl is already installed as mentioned earlier needed to download 2 library files. – temp-learn Nov 29 '11 at 06:11