Jump to content

Archived

This topic is now archived and is closed to further replies.

freeloader

Posting hidden form values with cURL

Recommended Posts

I'm writing an app that works through a couple steps of a sign in process.

This is the form:

[code]      <form action="register.dt" method="post">
      <input type="hidden" name="step" value="4">
      <input type="hidden" name="username" value="myID">
      <input type="hidden" name="password" value="mypass">
      <input type="hidden" name="email" value="mye-mail@jetable.org">
      <input type="hidden" name="password2" value="mypass">
      <input type="hidden" name="email2" value="mye-mail@jetable.org">
      <input type="hidden" name="referid" value="">
      <input type="hidden" name="firstname" value="Bakth">
      <input type="hidden" name="lastname" value="Hally">
      <input type="hidden" name="gender" value="Male">
      <input type="hidden" name="dob_month" value="01">
      <input type="hidden" name="dob_day" value="12">
      <input type="hidden" name="dob_year" value="1970">
      <input type="hidden" name="country" value="US">
      <input type="hidden" name="address" value="">
      <input type="hidden" name="city" value="">
      <input type="hidden" name="state" value="">
      <input type="hidden" name="zip" value="">
      <input type="hidden" name="phone" value="">
      <input type="hidden" name="race" value="1">
      <input type="hidden" name="subclass" value="1">
      <tr>
        <td colspan="2" class="box_header"><b>Step 4: Rules and Account Recovery</b></td>
      </tr>
      <tr>
        <td colspan="2" class="box_content">
          <input type="checkbox" name="iagreetoterms" value="1"> I have read and agree to the <a href="tos.dt" target="_blank">Terms of Use</a>.<br>
          <br>
          <input type="checkbox" name="iagreetoantispam" value="1"> I have read and agree to the <a href="antispam.dt" target="_blank">Anti Spam Policy</a>.<br>
          <br>
          <input type="checkbox" name="iagreetorules" value="1"> I have read and agree to the <a href="rules.dt" target="_blank">Rules</a>.<br>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="box_content">
          <b>Security Code</b><br>
          <br>
          <font class="small">Please enter a security code. This code will be used for claiming prizes, change of address, loss of account, and other site-related functions. We suggest you print your security code and save it in your records. </font>
          <br>
          <br>
          <select onchange="javascript: if (this.options[this.selectedIndex].value == 'custom') { document.getElementById('customq').style.visibility = 'visible'; } else { document.getElementById('customq').style.visibility = 'hidden'; }" name="security_question">
            <option>Whats your mother's maiden name?</option>
            <option>Whats your pet's name?</option>
            <option value="custom">Other (specify below)</option>
          </select><br>
          <div id="customq" style="visibility: hidden">
            Question <input value="" type="text" name="custom_question">
          </div>
          Security Word <input value="" type="text" name="securitycode"><br>
        </td>
      </tr>
      <tr>
        <input type="hidden" id="submit" name="submit" value="TRUE">
        <td align="right" colspan="2" class="box_content"><input src="templates/notloggedin/images/buttons/continue.gif" type="image"></td>
      </tr>
      </form>[/code]

I'd like to know how I can include the hidden fields in my cURL request.

This is my current cURL setting:

[code] $url = "http://www.darkthrone.com/register.dt";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0";
$question = "Whats your mother's maiden name?";
$postfield4 = "race=1&subclass=1&iagreetoterms=1&iagreetoantispam=1&iagreetorules=1&security_question=".$question."&securitycode=fadzilah&x=47&y=142";
$postfieldsize4 = strlen($postfield4);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
//curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_TIMEOUT,2000);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield4);
//curl_setopt($ch, CURLOPT_POSTFIELDSIZE, $postfieldsize4);
$res=curl_exec($ch);
curl_close($ch);[/code]

As you see, I included the postfields yet to be posted, but I have no clue how to include the hidden postfields as it is also necessary data to be sent.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.