Vallo Reima wrote:
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).


AFAICS $c contains the response output of the URL which you POSTed to using
fputs() - which is the return value of send_host(), so unless you echo the
contents of $c (assuming you are not outputting anything else) you will
not see the output returned when you do a POST request to the URL passed to
the send_host() function ...

I might be missing the point completely, but what exactly is the problem?
you seem to do a POST hit on a url get some output returned and then display
this as if it were your own page... and that seems to be what you want it to 
do...?

rgds & not-quite-seeing-the-problem,
Jochem

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



Reply via email to