Hi,
I am using a script to send VARIABLES to a REMOTE SERVER that only accepts POST method.
The PHP post script I am using is:
<?php
function post_send_headers ($fp)
{
fputs ($fp, "Accept: /\n");
fputs ($fp, "Accept-Language: en\n");
fputs ($fp, "Connection: Keep-Alive\n");
fputs ($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n");
}
function post_data ($host, $url, $data, $port=80)
{
if (strlen($host)<1)
return false;
if (strlen($url)<1)
return false;
if ((!is_array($data)) || sizeof($data)<1)
return false;
$fp = @fsockopen ($host, $port, $errno, $errstr, 120);
$ret = "";
//if (strncasecmp ($url, "http://", 7) == 0) $url = substr ($url, 7);
$req = substr ($url, $p);
if ($fp)
{
fputs ($fp, "POST $req HTTP/1.0\n");
post_send_headers ($fp);
fputs ($fp, "Content-type: application/x-www-form-urlencoded\n");
$out = "";
while (list ($k, $v) = each ($data))
{
if(strlen($out) != 0) $out .= "&";
$out .= rawurlencode($k). "=" .rawurlencode($v);
}
$out = trim ($out);
fputs ($fp, "Content-length: ".strlen($out)."\n\n");
fputs ($fp, "$out");
fputs ($fp, "\n");
while(!feof($fp))
{
$file_lines = file($fp);
}
fclose ($fp);
}
return $file_lines;
}
?>
This script works OK, but it shows the RESULT of the posting in the browser. How to change the RETURN to AVOID showing the visitor of my site that a FORM was automatically send to get a VARIABLE from another SERVER.
In this case I want to calculate the value of shipping charges.
Please, help.