anointing Posted September 25, 2008 Share Posted September 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125861-solved-code-to-direct-shoppers-back-to-referring-page-on-pressing-a-button/ Share on other sites More sharing options...
sKunKbad Posted September 25, 2008 Share Posted September 25, 2008 <form action="<?php echo $_SERVER['HTTP_REFERER']; ?>" method="post"> <input type="submit" value="go back" /> <form> Quote Link to comment https://forums.phpfreaks.com/topic/125861-solved-code-to-direct-shoppers-back-to-referring-page-on-pressing-a-button/#findComment-650835 Share on other sites More sharing options...
anointing Posted September 26, 2008 Author Share Posted September 26, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/125861-solved-code-to-direct-shoppers-back-to-referring-page-on-pressing-a-button/#findComment-651226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.