Dubya008 Posted May 4, 2010 Share Posted May 4, 2010 I've found the following PHP code from the ShopSite forum. I was told that it could be changed to post all of the data it is getting to a new URL. I'm not a PHP master so i'm having trouble following it. Can I get some help on where I'd post all of the data to a new URL?? <?PHP // Note: $_POST variable not available since this script is called as a // CGI script, so we have to read in our params from stdin, with length // determined by the CONTENT_LENGTH environment variable. // Read in POST parameters sent by ShopSite $stdin = fopen("php://stdin","r"); fscanf($stdin,"%{$SERVER['CONTENT_LENGTH']}s",$query_string); // And now we split the params into the $params array. parse_str($query_string,$params); if ( $params['cust_country'] && $params['item_total'] ) { // You would normally include code here for determining // your shipping rates and options. Remember that all input // parameters are in the $params array. // // The variables to set for the output (assuming you use the // output code included in this example) are $status, $options, // and $prices. $options and $prices are arrays. } else { $status="fail"; $error=urlencode("Params are ".var_export($params,true)); $option_count=0; } // Output data to ShopSite echo "status=".$status."\n"; echo "option_count=".$option_count."\n"; if ($status="fail") { echo "error=".$error."\n"; } for ( $option = 1; $option <= $option_count; $option += 1 ) { echo "s".$option."option=".$options["$option"]."\n"; echo "s".$option."price=".$prices["$option"]."\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/200614-script-for-posting-orders/ Share on other sites More sharing options...
beta0x64 Posted May 7, 2010 Share Posted May 7, 2010 I would give this a shot: http://www.php.net/manual/en/book.sockets.php I'm not sure how CGI-mode changes things... but if you must send it as a POST, you can use sockets to form how your browser would send it, then send it to your new PHP script at the other side of the cloud. Not that difficult, look for some tutorials. If you were an intrepid explorer, you could always make a proxy and catch your own POSTs, but if you could do that, you might be able to do this!!! Quote Link to comment https://forums.phpfreaks.com/topic/200614-script-for-posting-orders/#findComment-1054815 Share on other sites More sharing options...
ignace Posted May 7, 2010 Share Posted May 7, 2010 $SERVER['CONTENT_LENGTH'] should be $_SERVER['CONTENT_LENGTH'] if ( $params['cust_country'] && $params['item_total'] ) should be if ( isset($params['cust_country']) && isset($params['item_total']) ) if ($status="fail") should be if ($status=="fail") Quote Link to comment https://forums.phpfreaks.com/topic/200614-script-for-posting-orders/#findComment-1054824 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.