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] => dasd@hotmail.com [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&usr_name=dasd@hotmail.com&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....

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.