...

View Full Version : PHP curl help



java_freak
11-04-2009, 08:55 AM
i donno whether my question has issues here :o
i want to login www.codingforums.com via php curl
the code i was using is :

<?php
$url = "http://www.codingforums.com/login.php?do=login";
$postfields = "vb_login_username=java_freak&vb_login_password=&s=&securitytoken=&do=login";
$cookie_file_path = "cookiejar.txt";
$fp = fopen("$cookie_file_path","w") or die("<BR><B>Unable to open cookie file $mycookiefile for write!<BR>");
fclose($fp);
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
echo $result;

curl_close ($ch);

?>


i'm using Tamper data plugin for FireFox to get the post data..
do the datas that i supplied earlier is enough?
when i execute the script it says "Login successful. redirecting.."
but after redirecting it returned to the front page :confused:
can someone point me how to use cookies correctly(if thatz the case).
or a working example :thumbsup: i just wanna learn how it's done ;)
any lead is greatly appreciated :D

Phil Jackson
11-04-2009, 09:34 AM
and what will you be wanting our lovely coding forum's (notice the single quote, used for a certain reason) data for?

java_freak
11-04-2009, 10:50 AM
and what will you be wanting our lovely coding forum's (notice the single quote, used for a certain reason) data for?

i don't have any bad intentions :D ..just want a working example..
it's fine if u give me any other working examples that uses cookie to login using curl :thumbsup:

java_freak
11-04-2009, 11:37 AM
any working examples which uses cookies in curl login..please



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum