Jump to content


Photo

Redirection Question


  • Please log in to reply
2 replies to this topic

#1 ImJustBrndn

ImJustBrndn
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 22 August 2006 - 04:59 PM

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....p?act=add&pid=1

Thanks,
Brandon


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 22 August 2006 - 05:01 PM

You can redirect the user to a different page using the header command, assuming you haven't output anything to the browser:

header("Location: nextpage.php");



#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 22 August 2006 - 05:07 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users