title: PHP - How to Automatically Post Form in Another Website and Parse the Result
body: <p>I am new to screen-scaraping and curl. I am planning to create a website like what <a href="http://www.skyscanner.com.my/" rel="nofollow">http://www.skyscanner.com.my/</a> is doing that will allow a user to pull the origin, destination  and date from the <a href="http://airasia.com" rel="nofollow">http://airasia.com</a> website. Then the website return the flight schedule and ticket price to the user. The following is my code so far:</p>
  
  <p>code:</p>
  
  <pre><code>&lt;?php
  
  $post_data['Origin']=$_POST['origin'];
  $post_data['Destination']=$_POST['destination'];
  $post_data['From']=$_POST['departDate'];
  $post_data['To']=$_POST['returnDate'];
  
  
  foreach ($post_data as $key =&gt; $value)
  { 
      $post_items[] = $key . '=' . $value;
  }
  $post_string = implode ('&amp;', $post_items);
  
  
  $curl_connection = curl_init('https://booking.airasia.com/search.aspx');
  
  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);
  
  curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
  
  $result = curl_exec($curl_connection);
  
  print_r(curl_getinfo($curl_connection));
  echo curl_errno($curl_connection) . '-' . 
                  curl_error($curl_connection);
  curl_close($curl_connection);
  echo $result;
  ?&gt;
  </code></pre>
  
  <p>The above do not return me any result from air asia. So i need some guidance to continue my task. Thank You </p>