Hi all,

I'm trying to create a curl script that will query a remote server using php/cURL via a form submission.

- submit a form with two values (member id, postcode)
- 1 value is only numerical, postcode is alphanumeric
- if a result is found then display that NUMERICAL number on screen
- if no result then ++ add 1 to the starting member id string value and keep looping and submitting until a result is found
- the site also juses jsessionid?????

If no member match it will still go to result page but display Your search did not find anything. You have to manually (normally) click back to go back and enter different number.

I've created the following but doesn't work. any ideas how i could get it working?


   //create array of data to be posted
   $memberRef = 8372063;
   $postcode = 'N12+5qz';
   //create array of data to be posted
   $post_data['search.memberRef '] = $memberRef ;
   $post_data['search.postcode'] = $postcode;
   $post_data['search.searchT'] = '7';
   $post_data['search.searchS'] = '';   
   $post_data['Submit'] = 'Next';
   //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 = 
   //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
   echo curl_errno($curl_connection) . '-' . 
   //close the connection
echo $result;