Jump to content

[SOLVED] Code to Direct Shoppers Back to Referring Page on Pressing a Button


anointing

Recommended Posts

Hi,

 

I'm new to php and I'm working on a php shopping cart. I've already created a page for shoppers to check the status of their cart and have already implemented the functionality for displaying the cart for when it is empty and also when it has an item. Both functionalities are working correctly.

 

I now want to add an extra functionality for when the cart is empty whereby a button will appear, offering shoppers the option to continue shopping: on pressing the button, a shopper would then be directed back to the referring page. I'm already familiar with header("Location: goto.html"). I also know

$_SERVER['HTTP_REFERER'].

 

What I don't know is how to put the code together to direct a shopper back to his / her referring page only when they press the button.

 

I would really appreciate your help on this guys.

 

Hi

 

Thanks. Problem solved.

 

Owing to continuing browser inconsistencies in retrieving the referral URL, I will use javascript to direct shoppers to the home page on pressing the "Continue Shopping" button. This is almost the same as redirecting them back to actual referring pages because with good navigation throughout the site, they can readily move around anyway.

 

The site is still under construction; here's the php code snippet and it works:

 

echo "<input name='Submit' type='submit' value='CONTINUE SHOPPING' onclick='javascript:window.location=\"go_to_homepage.html\"' />";

 

Thanks for your help

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.