Page 1 of 1

cUrl page element

Posted: Sat Jan 24, 2009 4:25 pm
by astropirate
hi,
i am a newby in php and the cUrl library. i have been looking at tutorials and learning some wat :roll:
however i seem to be stuck. there is this page site.com/login.cfm the form needs 3 things: username, password and server. those are all set, however the Submit button doesn't have a name, it just has id and value. i goggled it but the search wasn't very fruitful. my question is how do i submit the form without the submit button having a name. any help would be greatly appreciated.

Re: cUrl page element

Posted: Sat Jan 24, 2009 4:51 pm
by William
cURL doesn't interact with the actual form at all. There is no reason that cURL would need the submit button to have a specific name. Can you elaborate a little on what you're trying to do and why it's not working?

Re: cUrl page element

Posted: Sat Jan 24, 2009 5:55 pm
by astropirate
sorry if i didn't give enough information

this is what i am working with:

Code: Select all

 
<tr><td></td><td>&nbsp;<input type=submit value="   Login   "  style="border : solid 1px silver; color:yellow;"></td></tr>
 
as you can see the button doesn't have a name.

this is my code so far:

Code: Select all

function makecookie()
{
       $curl = curl_init("http://thesite.com/i.cfm");
    
      $user = "myusername";
       $password = "mypassword";
       $server = "2";
       curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie1.txt");
            curl_setopt ($ch, CURLOPT_REFERER, "http://uc.gamestotal.com/i.cfm");
      $formfields = array('nic' => $user, 'password' => $password, 'server' => $server); // here is where i am stuck. i don't know                                           //how to submit
 
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $formfields);
    curl_exec($curl);
        curl_close($curl);
        
}
 
By i don't know how to submit i mean how can i submit if i don't know how to refer to the submit button.

for example i got this working signing into another site by doing this:

Code: Select all

$formfields = array('username' => $name, 'password' => $password, 'login' => 'login');
"login" was the name of the button that was being used to submit. i don't know what to use in this situation thogh.

Re: cUrl page element

Posted: Sat Jan 24, 2009 7:10 pm
by William
All a button does is tell the browser to make a new request to the page set in the form's action attribute. The page processing the request obviously doesn't require any data from that button. In other words, don't worry about sending any extra parameters for that button. Sorry if that doesn't make sense, not exactly sure how to explain it to you.

Re: cUrl page element

Posted: Sat Jan 24, 2009 7:44 pm
by astropirate
to test what you were saying i took off

Code: Select all

'login' => 'login'
in my test code and it didn't work 8O .

perhaps you could tell me how i would modify my posted code so it doe what u are saying.

Re: cUrl page element

Posted: Sat Jan 24, 2009 8:04 pm
by William
Try this, if you use FireFox look into the addon named "Tamper Data". If you install it just go to the login form, go to Tools -> Tamper Data and then press the "Start Tamper" button. When you submit the form it will allow you to "tamper" with the data being sent to the server. This will give you an idea at what the form is sending to the server so you know how to imitate it.

Before you start getting into this I recommend reading the terms & polices for that site to make sure what you're doing isn't illegal.