I am trying to login into a forum by using Curl and the link of forum is
https://www.shaanig.org/login.php?do=login
my code can not log in into forum Because the link goes into homepage after loading
That's why i've loste the login forum
Let me know please , Thanks indeed
function vBulletinLogin($user, $pass)
{
$md5Pass = md5($pass);
$data = "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "https://www.shaanig.org/login.php?do=login"); // replace ** with tt
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt ($ch, CURLOPT_TIMEOUT, '10');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/codecall_$user.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/codecall_$user.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_close($ch);
$pos = strpos($store, "Thank you for Logging in");
if($pos === FALSE)
{
RETURN 0;
}
else
{
RETURN 1;
}
}
Change your curl option for follow location with this:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
It will curl not to follow 3xx header redirects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.