Hi there,

I've used curl with PHP4 without any notable problem.
Now I have to do the same things with curl and PHP5 and
it won't work.

<?php
$ch_1 = curl_init();
curl_setopt($ch_1, CURLOPT_URL, $url_1);
curl_setopt($ch_1, CURLOPT_VERBOSE, 1);
curl_setopt($ch_1, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch_1, CURLOPT_HEADER, 1);
curl_setopt($ch_1, CURLOPT_WRITEHEADER, $hfh);
curl_setopt($ch_1, CURLOPT_STDERR, $efh);
curl_setopt($ch_1, CURLOPT_RETURNTRANSFER, 1);
// ---- COOKIES ------------------------------------
curl_setopt($ch_1, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch_1, CURLOPT_COOKIEJAR, $cookie_file);
// ---- POST-VARS ----------------------------------
curl_setopt($ch_1, CURLOPT_POST, 1);
curl_setopt($ch_1, CURLOPT_POSTFIELDS, $postdata_1);
curl_exec($ch_1);
curl_close($ch_1);

?>

Is there anybody who knows where the problem could be and
can give me a link to fix it???

th

    what is the problem? saying it will not work does NOT help.

      You're right,

      First i using curl to request a simple site where a cookie is set which is writed correctly into the cookie_file.

      Then i request the same site again but curl don't send the cookie to the server.

      Unfortunately i get no error-message from curl.

      we uses

      PHP Version 5.0.4
      Apache/1.3.26
      libcurl/7.13.2 OpenSSL/0.9.7f zlib/1.2.1

      For futher informations i've attached the source code for both files

        9 months later

        Same problem here - I used cURL to login to a phpBB forum (not hacking - just using one example) and then tried to retrieve a page that can only be accesed by members. But the page I got was the login page.

        <?php
        $url = "http://www.phpbb.com/phpBB/login,php";
        $Data = "username=user&password=pass&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_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");
        
        curl_setopt ($handle, CURLOPT_URL, "http://www.phpbb.com/phpBB/privmsg.php?mode=post");
        curl_setopt ($handle, CURLOPT_POST, FALSE);
        
        $file_contents = curl_exec($handle);
        echo $file_contents;
        curl_close($handle);
        ?>
        

        The 1st curl_exec logs you in - but the 2nd one takes you back to the login page.

        Any idea how to get this resolved ?

          2 years later

          Well, i am definitely not an expert with curl, but maybe you should try executing the login, before tring to retrieve the member only page...

            mazzzzz wrote:

            Well, i am definitely not an expert with curl, but maybe you should try executing the login, before tring to retrieve the member only page...

            Generally speaking, there's not a lot of benefit to be gained by replying to threads that have been inactive for over 2 years.

              Write a Reply...