Hi Seb,
I was looking for some thing like you, and I saw your question. It helped me so much . Now I am returning to you parts of the program that works.
I hope it will be helpfull for you.
$ctrlf="\r\n";
$header = "POST /cgi-bin/cgi.cgi HTTP/1.1".$ctrlf;
$header .= "Content-type:application/x-www-form-urlencoded". $ctrlf;
$header .= "Content-length:" . strlen($request) . $ctrlf;
/ the host that I want to submit a request /
$header.="Host:my_server_destin.com.br\r\n" ;
/ the program that starts with the request /
$header .= "Referer:http://www.myurl_origin.com.br/site/program_origin.php\r\n\r\n";
$fp = fsockopen('my_server_destin.com.br', 80, &$err_num, &$err_msg, 30);
if ($fp) {
fputs($fp, $header.$request.$ctrlf);
/* searchs for the beginning of the HTML source returned by the */
/* server requested */
while( ( !feof($fp) ) && ( !$achou ) ) {
$linha = fgets($fp,1024);
if ( ereg("^Content-Type: text/html" , $linha) ) {
$linha = fgets($fp,1024);
$fpaux = $fp;
$achou = true;
}
}
..........
..........
while (!feof($fp)) {
$linha = fgets($fp, 1024);
echo $linha;
}