Page 1 of 1
curl login
Posted: Sat Nov 21, 2009 1:29 pm
by deldadeh
Hi i want to login a website with curl
and this is code
why it doesn't make any output and there is no result.
Code: Select all
$id =""; // my username
$password =""; // my pass
$secfrdcodedvar =""; // some value i get from the page
$frm-id=""; // some value i get from the page
$url=""; // address of <form> tag in action parameter
$POSTFIELDS = 'data[username]='.$id.'&data[password]='.$password.'&secfrdcodedvar='.$secfrdcodedvar.'&frm-id='.$frmid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $POSTFIELDS );
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec ($ch);
Re: curl login
Posted: Sat Nov 21, 2009 3:57 pm
by josh
Turn on error reporting
Re: curl login
Posted: Sun Nov 22, 2009 5:51 am
by deldadeh
josh wrote:Turn on error reporting
i turned it on but there is no error.
also i user header parameter, and sent me the successfull header, but i need the full page not just the header.
thanks
Re: curl login
Posted: Sun Nov 22, 2009 12:20 pm
by deldadeh
i mean this
the returned string is this
HTTP/1.1 100 Continue HTTP/1.1 302 Found Date: Sun, 22 Nov 2009 18:11:01 GMT Server: Apache/2.2.11 (Debian) X-Powered-By: Cloob Framework/1.0.1 Set-Cookie: PHPSESSID=54e51bd64e40e6bf3541345ee-895609; path=/; HttpOnly Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: PHPSESSID=54e51bd64e40e6bf3541345ee-895609; path=/ Set-Cookie: m_id=1258913462_7980061; expires=Thu, 08-Feb-2018 18:11:02 GMT; path=/ Location: /profile/main/home/username/systemuser Content-Length: 0 Connection: close Content-Type: text/html
i got from this header returned that it logined successfully. and now i want the complete page content.
and i use changed code to this:
Code: Select all
$ch = curl_init() or die( curl_error() );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13');
curl_setopt ($ch, CURLOPT_POSTFIELDS, $POSTFIELDS );
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_exec ($ch);
Re: curl login
Posted: Sun Nov 22, 2009 1:37 pm
by josh
Follow the http header redirect
Re: curl login
Posted: Sun Nov 22, 2009 1:45 pm
by deldadeh
josh wrote:Follow the http header redirect
how?
please help me.
explain more...

Re: curl login
Posted: Sun Nov 22, 2009 4:22 pm
by josh
Re: curl login
Posted: Mon Nov 23, 2009 12:38 pm
by deldadeh
hi thanks
but this error occurs.
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/mysite/public_html/curl/curl.php on line 58
and there is another question,
how can i save the output page into a file?
and save in my host
thanks