PHP Form Automatic Submission

Posted by sex stevens on Stack Overflow See other posts from Stack Overflow or by sex stevens
Published on 2012-11-04T05:29:50Z Indexed on 2012/11/04 23:00 UTC
Read the original article Hit count: 171

Filed under:

I need to create a PHP script that runs around the clock and re-submits a form without actually loading the form, just sending the same request over and over. I used a program called WireShark to record my packets and play them back using a packet player. This took two hours of troubleshooting and configuring. When everything finally worked, it turns out the end result was a dead end. The packets being sent did not affect anything.

This code is what the script needs to resubmit:

<a href="#" onclick="_('_tf11').value=15; return false;">(15)</a>
<input type="image" id="btn_train" class="dynamic_img" value="ok" name="s1" src="assets/x.gif" alt="Training">

Okay, I know that here on stackoverflow you can't just ask people to do your work. The problem is that I don't even know where to start here. So please at least give me a direction, or a function name or a lead on how to be able to submit this form. Then I'll write a program and you guys can help me finish it if I will need help.

here is what I made: The program:

<?php
//create array of data to be posted
$post_data['tf[11]'] = '10000';
$post_data['s1'] = 'ok';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection =
  curl_init('http://crusadertrav.com/build.php?id=33');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
                curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
?>

The forms:

<input type="text" class="text" id="_tf11" name="tf[11]" value="0" maxlength="4">
<input type="image" id="btn_train" class="dynamic_img" value="ok" name="s1"     src="assets/x.gif" alt="Training">

The result:

 Array ( [url] => http://crusadertrav.com/index.php [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 895 [request_size] => 350 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 1 [total_time] => 2.781 [namelookup_time] => 0 [connect_time] => 0.532 [pretransfer_time] => 0.532 [size_upload] => 0 [size_download] => 10655 [speed_download] => 3831 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0.954 [redirect_time] => 0.906 [certinfo] => Array ( ) [primary_ip] => 5.154.88.71 [primary_port] => 80 [local_ip] => 192.168.11.52 [local_port] => 3222 [redirect_url] => ) 0-

© Stack Overflow or respective owner

Related posts about php