Jump to content

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


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

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.