0

I am working on developing a an order management screen for an eCommerce solution that, when a link relative a specific order is clicked, will export information for that order and populate a page that is hosted on a different domain that is also owned by my company.

Here is a simplified, hypothetical version of my code:

foreach ($orders as $order_number) {
   echo '<a href="http://www.anotherdomain.com/shipping_info.php">View shipping info for Order #' . $order_number . '</a>';
}

Then I also have an array called $shipping_info containing individual arrays of info on each order.

This loop will create links to view information for each order number in the array. When the user clicks the link for "View shipping info for Order #100" they should be taken to the the http://www.anotherdomain.com/shipping_info.php page populated with info from $shipping_info[100], which is also an array.

What is the best way to accomplish this?

1
  • Are you loading all the data into this shipping_info or could you bring the data in again on the shipping_info page? You could pass the id through $_GET if both domains have access to the same db. May have to use CURL to pass xml otherwise. Commented Aug 2, 2013 at 16:29

2 Answers 2

1

I can think of two ways

  1. Using POST, make the button a form that's being submitted to the other domain with the data. This is fast and easy, but it doesn't allow you to verify the data on the second domain.

  2. Save the shipping info to a database with a random id, and link using that to http://www.anotherdomain.com/shipping_info.php?id=<random id>. This way, the data can't be tampered with and you can link the shipping info to somebody else. This does require websites to access the same database and can be a little more complex than the first solution.

Sign up to request clarification or add additional context in comments.

Comments

0

if its going across servers AFAIK your only hope is $_GET variables in the URL.

<a href="http://anotherdomain.com/shipping_info.php?stuff=(info you need to pass)&morestuff=(more info you need to pass)&evenmorestuff=(you get the idea by now)>View shipping info</a>

4 Comments

In some browsers (IE, Safari), GET posts are limited to 2KB of data, so that might be a problem for big shipping_info arrays.
@kba Yeah, i like your answer more than mine. But i believe passing everything in GET is his only option if they cant connect to same db. So SOL if giant arrays.
No, using POST instead of GET is very similar to your suggestion, but doesn't invoke the 2KB limit.
Thanks for the info. I don't think this array is more than 2K. However, I was hoping there would be a way to pass the data other than GETting it from the URL, but the two files are on completely seperate servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.