Jump to content

Archived

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

ImJustBrndn

Redirection Question

Recommended Posts

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=1

Thanks,
Brandon

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.