Jump to content

Automatic login to remote website using curl


vishnuvdev

Recommended Posts

Hi,

I'm trying to auto login to a website(created by me ;-) ) using the curl. as I am new to this I don't know how to make this possible.

 

following is the code I tried but this is not submitting the data in the other site. the 'usr_name' and 'password' the field names in the page  "http://localhost/myproject/users/login". and I have given a print_r in that site and it is displaying

 

Array ( [loginType] => L [step] => confirmation [usr_name] => [email protected] [password] => test123 )

but not submitting the form.

 

please help me....

 

this is the code i've tried..I got this from web...

 

 

 

 

$login = "http://localhost/myproject/users/login";

$param="loginType=L&step=confirmation&[email protected]&password=test123";

$c = curl_init();

curl_setopt($c, CURLOPT_URL, $login);

 

curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt");

curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt");

curl_setopt($c, CURLOPT_POST, 1);

curl_setopt($c, CURLOPT_POSTFIELDS, $param);

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);

echo curl_exec($c);

 

 

thanks in advance....

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.