Page 1 of 1

Help with File Command

Posted: Wed Nov 24, 2010 9:08 pm
by Duelist
I am new to PHP but I have a good background in C++. I am trying to make a simple real time rate calculator for an online shopping cart for calculating freight rates for shipping.

To make it simple for the third party creators of the shopping cart to switch over to my rate calculator I am trying to make it work like one they already use for a different freight company.

The shopping cart is using PHP and sends the data to the other RTR using the PHP File command as per below.

$myfile = file('http://...../ratecalc.asp?Pickup_Postcode='.$ourpostcode.'&Destination_Postcode='.$postcode.'&Country='.$country.'&Weight='.$weight.'&Service_Type='.$service.'&Length='.$length.'&Width='.$width.'&Height='.$height.'&Quantity='.$quantity);

The RTR sends the data back to $myfile as though it had opened a normal file.

The RTR uses ASP to do this but I do not have access to a server that will run ASP so I am hoping to emulate what they are doing using PHP.

I have tried to find how to do this online but am not having much luck.

Can I create a ratecalc.php file that will send data back to the file command in my original php file?

I did a trial just to see by creating ratecalc.php and putting a print statement inside and it obviously did not work. But it also came up with an error message saying that the file command could not access a stream so I am assuming that the ratecalc.php somehow has to create a file stream.

Thanks

Re: Help with File Command

Posted: Wed Nov 24, 2010 10:31 pm
by Jonah Bron
Yes, you can do that. You can access the data (Pickup_Postcode, Destination_Postcode, etc) with $_GET. Then just echo out the result of the calculation (assuming that's what ratecalc.asp does).