Hello.

I have been sitting for 2 days and I don’t understand why it doesn’t work. No matter how I changed the code, it will not be authorized anyway. Please help, what is wrong here?

$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://nnm-club.ru/forum/login.php'); curl_setopt($curl, CURLOPT_USERAGENT, "Opera/10.00 (Windows NT 5.1; U; ru) Presto/2.2.0"); curl_setopt($curl, CURLOPT_REFERER, 'http://nnm-club.ru/forum/'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, 'username=nick&password=Qwerty123&autologin=1&returnto='); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt'); iconv("windows-1251","utf-8",curl_exec($curl)); curl_setopt($curl, CURLOPT_URL, 'http://nnm-club.ru/forum/viewtopic.php?t=480539'); curl_setopt($curl, CURLOPT_REFERER, 'http://nnm-club.ru/forum/'); echo iconv("windows-1251","utf-8",curl_exec($curl)); curl_close($curl); 
  • Does not support your hosting curl / most likely - user6938
  • No, his script example is not working, the post request is incorrectly compiled. - Alexis

1 answer 1

Here is a working example with my login and password:

 <?php $url = "http://nnm-club.ru/forum/login.php"; $referer = "http://nnm-club.ru/forum/"; $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"; $post = "username=Andrey+z668&password=dAJsB1lu&redirect=&login=%C2%F5%EE%E4"; $header [] = "Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1"; $header [] = "Accept-Language: ru-RU,ru;q=0.9,en;q=0.8"; $header [] = "Accept-Charset: Windows-1251, utf-8, *;q=0.1"; $header [] = "Accept-Encoding: deflate, identity, *;q=0"; //$proxy = "121.11.64.13:80"; $user_cookie = "cookies.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_HTTPHEADER, $header ); //curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, $user_cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $user_cookie); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); //curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $result = curl_exec($ch); curl_close($ch); echo $result; ?>