Jump to content

Help needed with:: Automated Search Form Submission cURL/PHP


jk2010

Recommended Posts

Hi all,

 

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

 

- 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.

 

Please help.

 

<?php

//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 = 
  curl_init('http://www.membersitename.com/search.do');

//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);
echo $result;	
?>

Link to comment
Share on other sites

hey guys, can anyone help?  :shrug:

 

What are you asking of us, to write a whole script for you on some variables that are completely unknown to us? This would be a more freelance thing. If you need help with problematic code, then ask us one step at a time. It's hard to help when you don't help yourself , or help yourself help us.

Link to comment
Share on other sites

hey guys, can anyone help?  :shrug:

 

What are you asking of us, to write a whole script for you on some variables that are completely unknown to us? This would be a more freelance thing. If you need help with problematic code, then ask us one step at a time. It's hard to help when you don't help yourself , or help yourself help us.

 

If you're not gonna help than don't bother writing anything here. You must be thick since you can't read my post which clearly lists all the code I've used so its not bloody freelancing you muppet.

Link to comment
Share on other sites

for all,

 

guys i'm simply asking for help with what do i need to add to my code but if people like oni-kun are only going to come here to criticise me then please don't bother, I don't need idiots like him ruining my thread.

 

Thank you.

:-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.