PHP使用cUrl提交表单

i want to submit any IP address to this site with cUrl . my cUrl options could not work correctly:

  $h = curl_init();

  curl_setopt($h, CURLOPT_URL, "http://www.whatismyip.com/ip-whois-lookup/"); 
  curl_setopt($h, CURLOPT_POST, true);
  curl_setopt($h, CURLOPT_POSTFIELDS, array(
  'IP' => '2.179.144.117',
  'submitted' => 'submitted'
  ));
  curl_setopt($h, CURLOPT_HEADER, false);
  curl_setopt($h, CURLOPT_RETURNTRANSFER, 1);

  $result = curl_exec($h);
  echo $result;

A quick check on the headers sent to that webpage, reveals that the "submitted" post variable should be set to true, not to submitted.

Remark: please note that whatismyip.com probably does not allow access to its tool by means of scraping.

Give your array data with http_build_query() function so that, it can be decoded correctly on requested IP:

curl_setopt($h, CURLOPT_POSTFIELDS, http_build_query(
   array(
      'IP' => '2.179.144.117',
      'submitted' => 'submitted'
   )
));
// echo http_build_query(array('IP' => '2.179.144.117', 'submitted' => 'submitted'));
// outputs: IP=2.179.144.117&submitted=submitted and this will be added to the end of
// the requested URL in GET request.