Jump to content

Script for Posting Orders


Dubya008

Recommended Posts

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"; 
} 

?>

Link to comment
Share on other sites

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!!!  :)

Link to comment
Share on other sites

$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")

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.