Note that there are some explanatory texts on larger screens.

plurals
  1. POcURL does not work
    primarykey
    data
    text
    <p>Well, I want to login using cURL on some page. When i paste this data in addressbar in that form in the browser <a href="http://mywebpage.net/login.php?username=HERESMYUSERNAME&amp;password=dded0102f44e7e0809520eb93055cb16" rel="nofollow">http://mywebpage.net/login.php?username=HERESMYUSERNAME&amp;password=dded0102f44e7e0809520eb93055cb16</a> page takes me to the address <a href="http://mywebpage.net/user.php" rel="nofollow">http://mywebpage.net/user.php</a> and everything works. Now i want to get the same effect by using cURL but something does not work.</p> <pre><code>$url="http://mywebpage.net/login.php"; $cookie="cookie.txt"; $postdata = "username=cow&amp;password=ass"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); if (!$result) { $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // make sure we closeany current curl sessions die($http_code.' Unable to connect to server. Please come back later.'); } echo $result; curl_close($ch); </code></pre> <p>it's showing me the login page with empty input's and it don't login me and move to the correct address. When I type www.mywebpage.net/user.php shows "Err 401"</p> <p>Working code here:</p> <pre><code>$url="http://mywebpage.net/login.php?username=user&amp;password=ddad0102f44e7f0800354eb11155cb16"; $cookie="cookie.txt"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); if (!$result) { $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // make sure we closeany current curl sessions die($http_code.' Unable to connect to server. Please come back later.'); } echo $result; curl_close($ch); </code></pre> <p>How i can now redirect myself to /all.php? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload