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?
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>
I can think of two ways
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.
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.