title: cURL to send form but remote server did not POST
body: <p>I am creating a plugin that sends a form automatically by using PHP cURL. Its result is good but the form was not posted by the server. Why is that?</p>
  
  <pre><code>//create array of data to be posted
  $post_data['full_name'] = $name;
  $post_data['email'] = $email;
  $post_data['subscription_type'] = 'E';
  $post_data['id'] = $id;
  
  //traverse array and prepare data for posting (key1=value1)
  foreach ( $post_data as $key =&gt; $value) {
      $post_items[] = $key . '=' . $value;
  }
  
  //create the final string to be posted using implode()
  $post_string = implode ('&amp;', $post_items);
  
  //create cURL connection
  $curl_connection = curl_init($target_url);
  
  //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);
  </code></pre>
  
  <p>This is the result of the code.</p>
  
  <pre><code>Array ( 
  [url] =&gt; http://www.remote-server.com/formcapture.php?v=28&amp;w=29 
  [content_type] =&gt; text/html 
  [http_code] =&gt; 200 
  [header_size] =&gt; 180 
  [request_size] =&gt; 302 
  [filetime] =&gt; -1 
  [ssl_verify_result] =&gt; 0 
  [redirect_count] =&gt; 0 
  [total_time] =&gt; 0.742828 
  [namelookup_time] =&gt; 0.015174 
  [connect_time] =&gt; 0.062791 
  [pretransfer_time] =&gt; 0.0628 
  [size_upload] =&gt; 75 
  [size_download] =&gt; 6122 
  [speed_download] =&gt; 8241 
  [speed_upload] =&gt; 100 
  [download_content_length] =&gt; 6122 
  [upload_content_length] =&gt; 75 
  [starttransfer_time] =&gt; 0.692776 
  [redirect_time] =&gt; 0 
  ) 0- 
  </code></pre>
  
  <p>This is the form that I want to send.</p>
  
  <pre><code>&lt;form class='subscription_form' id='subscription_form' method='POST' action='http://www.remote-server.com/formcapture.php?v=28&amp;w=29'&gt;
  &lt;div align='center'&gt;&lt;center&gt;
  &lt;p&gt;Full name&lt;br&gt;&lt;input type='text' name='full_name' size='20'&gt;&lt;/p&gt;
  &lt;/center&gt;&lt;/div&gt;
  &lt;div align='center'&gt;&lt;center&gt;
  &lt;p&gt;E-mail address&lt;br&gt;&lt;input type='text' name='email' size='20'&gt;&lt;/p&gt;
  &lt;/center&gt;&lt;/div&gt;
  &lt;input type='hidden' name='subscription_type' value='E'&gt;&lt;div align='center'&gt;&lt;center&gt;
  &lt;p&gt;&lt;input type='submit' value='Go »'&gt;&lt;/p&gt;
  &lt;/center&gt;&lt;/div&gt;
  &lt;input type='hidden' name='id' value='360'&gt;
  &lt;/form&gt;
  </code></pre>