Problem submitting a POST request "by hand"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I send the parameters from one php script to another via POST method. The solution works (see example below) but the receiver page loads ONLY if I include the echo $c; command after send_host (see PROBLEM!!! line). Otherwise a blank page loads without any error messages. The problem is same with Microsoft-IIS/5.1-PHP/5.0.3 and Apache/2.0.51-PHP/4.3.10... What can I do to get rid of this?
Thanks!
Vallo


function send_host($host,$path,$query,$others=''){
$d="POST $path HTTP/1.1\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n${others}User-Agent: Mozilla 4.0\r\nContent-length: ".strlen($query)."\r\nConnection: close\r\n\r\n$query";
if (!$h = fsockopen($host,80)) {
return -1;
}
else {
stream_set_timeout($h,10);
}
if (fputs($h,$d) === FALSE) {
return -2;
}
else {
$r = '';
while(!feof($h)) {
$r .= fgets($h, 128);
}
}
if (fclose($h) === FALSE) {
return -3;
}
else {
return $r;
}
}


/* ... */

$c = send_host("$host_name","$redirect","$par");
if ($c < 0) {
   echo "<B>ERROR $c</B>";
} else {
   echo $c; /* PROBLEM!!! */
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux