ImJustBrndn Posted August 22, 2006 Share Posted August 22, 2006 I've got a fully working shopping cart script that I created. I have everything working just fine, but for a final addon I would like it so when you click the link to add a product to your cart that it redirects you to the shopping cart or to some kind of verification page. Does anyone know how to do this, do I need to add something into my cart_func.php script. The link to add something to my cart is:http://www.mydomain.com/folder/Cart_func.php?act=add&pid=1Thanks,Brandon Quote Link to comment https://forums.phpfreaks.com/topic/18313-redirection-question/ Share on other sites More sharing options...
hitman6003 Posted August 22, 2006 Share Posted August 22, 2006 You can redirect the user to a different page using the header command, assuming you haven't output anything to the browser:[code]header("Location: nextpage.php");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18313-redirection-question/#findComment-78661 Share on other sites More sharing options...
ober Posted August 22, 2006 Share Posted August 22, 2006 Keep in mind that you must have an intermediary page (or at least the processing code) between the clicking of "add to cart" and the header() call.I assume you're putting all of your items in a form. So when the action of the form that has the "add to cart" button should be something like "<form action="Cart_func.php?act=add" method="post">" Then of course your pid would be passed from the form itself, or however you're handling it.Cart_func.php should be nothing but the processing of adding that item to the shopping cart and then the header() call to go to the actual cart page. This also provides the added bonus of not having the user hit refresh and add the item to the cart again.I hope that all makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/18313-redirection-question/#findComment-78667 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.