jk2010 Posted January 3, 2010 Share Posted January 3, 2010 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/ Share on other sites More sharing options...
jk2010 Posted January 3, 2010 Author Share Posted January 3, 2010 are there no curl/php experts here? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/#findComment-987702 Share on other sites More sharing options...
jk2010 Posted January 8, 2010 Author Share Posted January 8, 2010 hey guys, can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/#findComment-990814 Share on other sites More sharing options...
oni-kun Posted January 8, 2010 Share Posted January 8, 2010 hey guys, can anyone help? 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. Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/#findComment-990824 Share on other sites More sharing options...
jk2010 Posted January 8, 2010 Author Share Posted January 8, 2010 hey guys, can anyone help? 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. Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/#findComment-990870 Share on other sites More sharing options...
jk2010 Posted January 8, 2010 Author Share Posted January 8, 2010 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. :-) Quote Link to comment https://forums.phpfreaks.com/topic/187015-help-needed-with-automated-search-form-submission-curlphp/#findComment-990876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.