tags:

views:

98

answers:

2

I have a form created with 2 fields and a submit button. But i want to do the same thing using Curl.

i tried it by using following code:

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);

$result = curl_exec($ch);
curl_close($ch);

$fields included the two fields.

but the required output never came.

is there a way to do this successfully?

A: 

To get output set CURLOPT_RETURNTRANSFER in TRUE:

curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
Dmitry Merkushin
A: 

Also, be sure to set CURLOPT_FOLLOWLOCATION to TRUE if the url supplied redirects at all using a Location: header....

eCaroth