Forum Moderators: coopster
I'd like to make a script that makes submitting form easily. When the form is submitted, I'd like to redirect them to the result page on the remote server and leave my server.
I try to do this by the following script, and the result is stored at $result.
If I echo it, I'll web-fetch their content, and that's not what I want. I want to redirect my users to $result, i.e, they'll leave my server, and go to the form's server directly.
How could I redirect my users directly to $result? Thanks! Any contribution is appreciated!
Here's a simple example to handle a single remote form (actually I need to handle a few hundred similar form, so it's not so good to copy their form's html. )
<?php
$post_data['searchname'] = 'search_string';
$post_data['ordering'] = 'date';
foreach ( $post_data as $key => $value) {
$post_items[] = $key . "=" . $value;
}
$post_string = implode ("&", $post_items);
$curl_connection = curl_init("http://THE-URL-of-The-Remote-Form");
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);