tableman Posted August 13, 2010 Share Posted August 13, 2010 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 iframe height is a problem 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 and not having to fiddle with javascript. The first PHP code I try is prevented from working and I discover that the apparent cause is the issue of fopen and fsockopen etc. being set to off by the host that I use because of security concerns: $url="http://remote_server.cgi"; foreach($_POST as $key => $value) {$url .="$key=" . urlencode($value) . "&";} $array = file($url);] The host has cURL so I try that but the form entries are not being accepted as they are with a direct post from the form: $URL="http://remote_server.cgi"; $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 is a problem at the remote server, 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... " Apparently the post data is not being sent like the form sends it. Any suggestions? Quote Link to comment Share on other sites More sharing options...
tableman Posted August 14, 2010 Author Share Posted August 14, 2010 The host runs PHP version 4.3.11. The posted fields are not themselves arrays. CURLOPT_POSTFIELDS may expect $_POST to be urlencoded and in querystring format, so I added: $postfields=array(); foreach($_POST as $key=>$val) $postfields[]="$key=".urlencode($val); $postfields = join("&", $postfields); However, same error message. Anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.