Im trying to login to my useraccount on a site i use to download files from so i can automatically grab the file without me having to visit the site.
This is the form:
<form method='post' action='/news.php'>
<div>
Username: <input class='tbox' type='text' name='username' size='15' value='' maxlength='20' />
Password: <input class='tbox' type='password' name='userpass' size='15' value='' maxlength='20' />
<input type='hidden' name='autologin' value='1' />
<input class='button' type='submit' name='userlogin' value='Login' />
</div>
</form>
Here is the PHP ive got so far.
<?php
$username="my_user";
$password="my_passs";
$url="the_url";
$cookie="cookie.txt";
$postdata = "username=".$username."&userpass=".$password;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
?>
Am i doing something wrong? It just displays the website at the moment but doesn't log me in. Ive never used Curl before.
Thanks
username
andpassword
posts? Maybe you are checking ifuserlogin
field is set?name='userpass'
and$password="my_passs";
change it to$userpass="my_passs";
should work now. @Exoon