php - How do you send a CURL POST request to the second form from the same page as the first form? -


there 2 forms on html page , want send through curl post request second form.

the forms of format:

<form name="cod" action="/form.html" method="post">     <input type="text" name="cod" class="form2">     <input type="hidden" name="page" value="domains">     <input name="b1" type="submit" class="form1" value="view"> </form> <br/><br/> <form name="cod" action="/form.html" method="post">     <select name="an">         <option value="1">1</option>         <option value="1">2</option>     </select>     <input type="hidden" name="cod" value="302">     <input type="hidden" name="captcha" value="null">     <input name="method.b" type="submit" class="form1" value="view"> </form> 

the script used send post request first form following:

// set link $url = 'http://www.someurl.com/form.html';   // set form fields $payload = array(     'page' => 'domains',     'cod' => '30885923',     'isajaxrequest' => 'false' ); function curlpost($posturl, $postfields) {      $useragent = 'mozilla/5.0 (macintosh; u; intel mac os x 10.5; en-us; rv:1.9.2.3) gecko/20100401 firefox/3.6.3'; // setting useragent of popular browser      $cookie = 'cookie.txt'; // setting cookie file store cookie      $ch = curl_init();  // initialising curl session      // setting curl options     curl_setopt($ch, curlopt_ssl_verifypeer, false);    // prevent curl verifying ssl certificate     curl_setopt($ch, curlopt_failonerror, true);    // script should fail silently on error     curl_setopt($ch, curlopt_cookiesession, true);  // use cookies     curl_setopt($ch, curlopt_followlocation, true); // follow location: headers     curl_setopt($ch, curlopt_returntransfer, true); // returning transfer string     curl_setopt($ch, curlopt_cookiefile, $cookie);  // setting cookiefile     curl_setopt($ch, curlopt_cookiejar, $cookie);   // setting cookiejar     curl_setopt($ch, curlopt_useragent, $useragent);    // setting useragent     curl_setopt($ch, curlopt_url, $posturl);    // setting url post      curl_setopt($ch, curlopt_post, true);   // setting method post     curl_setopt($ch, curlopt_postfields, $postfields);  // setting post fields array      $results = curl_exec($ch);  // executing curl session     curl_close($ch);    // closing curl session      return $results; } //run function $rawdata = curlpost($url, $payload); 

this returns correctly result first form, how specify next want send post request second form?

i'm thinking of somehow mentioning name of input type="submit" field, no idea how. i've been searching hours both on stackoverflow , rest of internet.

help please?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -