Users make entries into a form on my site which are then sent to a remote server which generates a variable length page of results for the users’ perusal. I want the results to be displayed on my site but I discover that there is a problem with iframe height so I am trying PHP in a separate file to avoid an iframe. Then maybe I can cache the result pages and display them without any height difficulties. I am trying PHP first before resorting to Javascript to handle the iframe height.
The first PHP code I try generates a "… no wrapper… " error and I discover that the apparent cause is the issue of fopen and fsockopen etc. being set to “off”, because of security concerns, by the host that I use:
$url="http://remote_server.cgi";
foreach($_POST as $key => $value)
{$url .="$key=" . urlencode($value) . "&";}
$array = file($url);]
The host runs PHP version 4.3.11 and has cURL so I try that but the form entries are not being accepted as they are with post direct from the form:
$URL="http://remote_server.cgi";
$postfields=array(); //FOR urlencode and querystring expected by CURL_POSTFIELDS
foreach($_POST as $key=>$val) $postfields[]="$key=".urlencode($val);
$postfields = join("&", $postfields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_exec ($ch);
curl_close ($ch);
In case useragent recognition was another security issue at the remote server causing a refusal to accept the data, I added:
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
I know all entries are received by the separate file by using:
print_r($_POST);
But the remote server still says "Error in form found. You are not authorized… etc. etc… "
This code must not be sending the post data like the form does.
What fixes can I try?