Using PHP and cURL to login to indyarocks.com
- by Divya
I am new to cURL and don't know much about it. I basically want to login to my account on www.indyarocks.com through libcurl for PHP. I don't know what type of authentication it uses (I don't know how to find that out.). When I go to http://www.indyarocks.com, I get a login form which asks for my username and password. I put in my username and password and click login and everything is good. I tried to automate this using cURL. This is a snippet of my code.
curl_setopt($curl_connection, CURLOPT_URL, "http://www.indyarocks.com/loginchk.php");
curl_setopt($curl_connection, CURLOPT_POST, 1);
curl_setopt($curl_connection, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl_connection, CURLOPT_USERPWD, $username.':'.$password);
I looked at the source of the login page and found out the address of the page to which the username and password are sent (the action attribute of the form) which is "http://www.indyarocks.com/loginchk.php" and set it as the target url. When I run this, I get username or password is wrong error and the login fails. My username and password is correct. I don't know what the problem is. Can the password be encrypted? Can that be responsible for this failure?
Please help me get around this problem. I'll be really thankful.
Thanks in advance.