Page 1 of 1

Trying to login with curl but no luck

Posted: Thu Aug 28, 2008 1:46 pm
by hexbase
Hi,

I've been trying a few scripts to login to a friend's site but i've no luck. For example, 2 scripts show as output the login page but it hasn't logged in.

Check this, for example. This script shows the login page as output, but hasn't logged in. Tell me what i should do:

Code: Select all

 
<?
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, "http://www.thesite.com/login.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
 
curl_setopt($ch, CURLOPT_POSTFIELDS, 'usuario=&pass=&&submit=Login');
 
echo curl_exec($ch);
curl_close($ch);
?>

Thanks!

Re: Trying to login with curl but no luck

Posted: Tue Sep 02, 2008 5:29 pm
by andyhoneycutt
Are you sure that the page login.php actually post back to itself? If login.php's form is posting to say 'dologin.php' or something of that nature, your cURL script will fail.