I want to gather info from a user on a local php page (that I control), and use that info to query a form on another site (that I don't control) - how do I do that?

+5  A: 

Have your local form post the data to your local processing script. Then use something like curl to programmatically post the data to the remote server and receieve a response. You will then have to parse the reponse in some way to retrieve meaningful information.

+2  A: 

if you are using linux i suggest curl but here is a generic class i use http://willwharton.com/http.phps that works on linux and windows as it can use both curl and fsockopen()

$http = new Http();
$http->addParam('aaaa'  , 'bbb');
$http->addParam('ccccc'  , 'ddddd');
$raw = $http->result;
This is exactly what I needed 4 hours ago, before I started on the ugly javascript, forms and iframe solution i just completed :p
+5  A: 

Here's the code I ended up using, using curl:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $formurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "user_id=$id&password=$pw");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // required to work with https:// sites.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_exec() returns page, instead of printing it.
$page = curl_exec($ch);
if ($page == false) {
$curlerror = curl_error($ch);
print "<br>Errors: $curlerror<br>\n";
else {
print "<br>curl call succeeded<br>\n";
print $page;

There is a curl extension for PHP in Windows as well.

+1  A: 

What version of PHP are you using? I will assume 5.x.

PHP includes easy to use classes for HTTP operations. The documentation can be found here: http://us3.php.net/manual/en/ref.http.php

There are several ways to approach this: one is capturing the input on your local form and POST-ing the data to the remote form using http_post_fields().



Keep in mind, when posting data from one server to another, that foreign server may ignore your request. So be sure to test against that, and if you are unsuccessful, contact the person who has access to configure the server to accept requests from your local server.