Hi,
I'm new to php and am currently developing a php shopping cart. I've 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.
I now want to add an additional functionality for when the cart is empty whereby a button will appear offering shoppers the option to continue shopping: on pressing the button, they would then be directed back to the referring page. I'm already familiar with header("Location: goto.html").
What I would like to know is the code to implement the extra functionality mentioned above
that is triggered when the button is pressed.
I would really appreciate your help on this guys.
Sending Visitors Back to Referring Page on Pressing a Button
Moderator: General Moderators
Re: Sending Visitors Back to Referring Page on Pressing a Button
I would not count on HTTP_REFERER because it's a user data (e.g. some browsers will not send it).
Instead, in every page save the page url in a session variable. This way you'll have "the previous" page URL available.
Instead, in every page save the page url in a session variable. This way you'll have "the previous" page URL available.
There are 10 types of people in this world, those who understand binary and those who don't
- The_Anomaly
- Forum Contributor
- Posts: 196
- Joined: Fri Aug 08, 2008 4:56 pm
- Location: Tirana, Albania
Re: Sending Visitors Back to Referring Page on Pressing a Button
Perhaps every link to the shopping cart could have a URL variable "referrer" that has the name of the page, and with that, the shopping cart's "Go back" link would be populated.
Re: Sending Visitors Back to Referring Page on Pressing a Button
Hi
In view of continuing browser inconsistencies in retrieving the referral URL, I've decided to use javascript to point shoppers to the home page when they press the "Continue Shopping" button. This is pretty much 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
In view of continuing browser inconsistencies in retrieving the referral URL, I've decided to use javascript to point shoppers to the home page when they press the "Continue Shopping" button. This is pretty much 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
- The_Anomaly
- Forum Contributor
- Posts: 196
- Joined: Fri Aug 08, 2008 4:56 pm
- Location: Tirana, Albania
Re: Sending Visitors Back to Referring Page on Pressing a Button
I assume you know that a good portion of users will block javascript, which would render your button useless. Heck, No-Script is probably the most popular Firefox add-on I've heard of.anointing wrote:Hi
In view of continuing browser inconsistencies in retrieving the referral URL, I've decided to use javascript to point shoppers to the home page when they press the "Continue Shopping" button. This is pretty much 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