Note that there are some explanatory texts on larger screens.

plurals
  1. POloggin in with curl
    primarykey
    data
    text
    <p>I'm trying to get the below cURL operation to login on a bangme.net picture rating site. When I inspect the login form, the IDs are signin_UserName, signin_UserPass. The names are signin$UserName, signin$UserPass. The script doesn't seem to work with the underscore as the result leads me to a page that asks me to login as far as I can tell. I'm not able to use the dollar sign names as it turnes it into a variable. I notice some examples of this and similar scripts show some fields starting with the '&amp;' sign when it doesn't have that on the form on the webpage for which they want to login to. What does this do? Any assistance you can provide would be much appreciated. Thank you.</p> <pre><code>$username = "username"; $password = "password"; $url = "http://www.bangme.net/starform.aspx"; $cookie = "cookie.txt"; $postdata = "signin_UserName=" .$username . "signin_UserPass=" .$password; $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); echo $result; curl_close($ch); </code></pre> <p>new code:</p> <pre class="lang-php prettyprint-override"><code>$username = "username"; $password = "password"; $url = "http://www.bangme.net/signin.aspx"; $cookie = "cookie.txt"; $post = array( '__EVENTTARGET'=&gt;"" , '__EVENTARGUMENT'=&gt;"", '__VIEWSTATE'=&gt;"/wEPDwUJMzQ0MjU1MjA0ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAwUJbGFzdHBob3RvBQh2b3RleWVzMgUHdm90ZW5vMgfkai25gOMuDdbmzYMWHA2LgYKt", '__EVENTVALIDATION'=&gt;"/wEWDgLmnpGMBwKOwMbqCwK4wb4IAv/10agEAqHH7a8KAtXfk+ULAt/Q94gCAvS2udYOAqrdhtcHAq+k5d0LAo+Au5MKApm/3+0OAqDCuuYMArCmgTeosqrEgmB3P5bavC40rTc6dbeF1g==", 'signin$UserName'=&gt;$username , 'signin$UserPass'=&gt;$password , 'signin$Button1.x'=&gt;42, 'signin$Button1.y'=&gt;17 ); $postData = http_build_query($post); $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);//changed from 0 to 1 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//new curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//new curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_POST, 1); $result = curl_exec($ch); echo $result; curl_close($ch); </code></pre>
    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.
    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