Code: Select all
<?php
$url = "http://forums.devnetwork.net/login.php"; // This was edited in my Edit Post - changed index.php to login.php
$Data = "username=username&password=password&login=Login";
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL, $url);
curl_setopt ($handle, CURLOPT_POST, TRUE);
curl_setopt ($handle, CURLOPT_POSTFIELDS, $Data);
curl_setopt ($handle, CURLOPT_HEADER, TRUE);
curl_setopt ($handle, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, TRUE);
// curl_setopt ($handle, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt ($handle, CURLOPT_REFERER, "localhost");
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt ($handle, CURLOPT_FAILONERROR, 1);
curl_setopt ($handle, CURLOPT_COOKIEFILE, "D:/xxx/cook.txt");
curl_setopt ($handle, CURLOPT_COOKIEJAR, "D:/xxx/cook.txt");
$file_contents = curl_exec($handle);
curl_setopt ($handle, CURLOPT_URL, "http://forums.devnetwork.net/privmsg.php?mode=post");
$file_contents = curl_exec($handle);
echo $file_contents;
curl_close($handle);
?>
shows the login page - not the post msg page. The first curl_exec() did get me logged in - but the second one was being treated as one without the cookies being sent I guess. Thats why I thought I had to do the 2
curl_setopt ($handle, CURLOPT_COOKIE, $cookie_data); for the phpbb2mysql_data and phpbb2mysql_sid - but this I hoped could be sent automatically instead of me extracting it and then sending it back.
EDIT : It worked !