So you didn't like my other answer? Ok here is the code I posted before.
function callpage($page) {
global $HTTP_SERVER_VARS, $HTTP_POST_VARS;
$hostname = $HTTP_SERVER_VARS["HTTP_HOST"];
$url = parse_url($page);//Parse $uri into parts - path, query
//prepare entity-body
$method = "GET ";
$data = array();
$post = $HTTP_POST_VARS;
for (reset($post); $key = key($post); next($post)) {
if (strtoupper(substr($key,0,8)) != "BROWSER_") {//don't include
$data[$i]["NAME"] = $key;
$data[$i]["VALUE"] = $post[$key];
$i++;
}
}
if ($data) {
$method = "POST ";
$request = $data[0]["NAME"]."=".urlencode($data[0]["VALUE"]);
for ($i = 1; $i < count($data); $i++) {
$request .= '&'.$data[$i]["NAME"]."=".urlencode($data[$i]["VALUE"]);
}
}
if (isset($url["query"])) {
$request .= '&'.$url["query"]; //append command line arguments
}
// Build the REQUEST header
$header = $method.$url["path"]." HTTP/1.0\n";
$header .= "Content-type: application/x-www-form-urlencoded\n";
$header .= "Host: $hostname\n";
$header .= "User-Agent: ".$HTTP_SERVER_VARS["HTTP_USER_AGENT"]."\n";
$header .= "Content-length: ".strlen($request)."\n\n"; //last header line
//Open 3rd-party connection
$fp = fsockopen($url["host"], 80, $err_num, $err_msg);
if ($fp) {
fputs($fp, $header.$request);
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}
fputs($fp, "Connection: close\r\n\r\n");
fclose($fp);
}
}
WARNING: I stripped this code out of a functioning app that I have so I may have introduced some bugs in converting it. But it does do what you basically want it to do.