redirect to requested page
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
redirect to requested page
Hi,
I am setting up a shopping cart.
When a customer adds an item to their shopping cart and the action for adding that item is carried out, how do I redirect the customer back to the page from which the item was added?
or
How can I add the item and simply refresh the current page from which the item was added?
Thanks.
Nick
I am setting up a shopping cart.
When a customer adds an item to their shopping cart and the action for adding that item is carried out, how do I redirect the customer back to the page from which the item was added?
or
How can I add the item and simply refresh the current page from which the item was added?
Thanks.
Nick
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
So basically, you want to view the dvd... lets say "Exorcist" , and you hit add to cart. You want it to add to the cart, and then redirect back to the page automatically or provide a link?
Well If you would like to provide a link you can just $_POST the HTTP_REFERER (not reliable).
So you can do this on the add to cart page.
I am not sure if that is what you mean.
Well If you would like to provide a link you can just $_POST the HTTP_REFERER (not reliable).
So you can do this on the add to cart page.
Code: Select all
<?
$lastpage = $_SERVER['HTTP_REFERER'];
echo "<a href=$lastpage>Go Back To the Item</a>";
?>- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
I would like to be able to automatically go back to the original page.
I understand what you say but I don't know how to 'pick up'/store the original page url!
i.e. if I was to store the original page url in a session variable how would I literally do this? What would the code look like?
How would I set $lastpage and when would I set it.
Thanks for your patience.
I understand what you say but I don't know how to 'pick up'/store the original page url!
i.e. if I was to store the original page url in a session variable how would I literally do this? What would the code look like?
Code: Select all
<?
$lastpage = $_SERVER['HTTP_REFERER'];
echo "<a href=$lastpage>Go Back To the Item</a>";
?>Thanks for your patience.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
- blacksnday
- Forum Contributor
- Posts: 252
- Joined: Sat Jul 30, 2005 6:11 am
- Location: bfe Ohio :(
Not all browsers pass Referrer Info.
From my logs, I have found it is sometimes hard to rely on it.
This is what I use on all my rating forms
which allows any rating on any page to return
back immediately to the article they were on
without even knowing it
So if they voted on comment.php?bash=4
they return right back to it after rating it.
From my logs, I have found it is sometimes hard to rely on it.
This is what I use on all my rating forms
which allows any rating on any page to return
back immediately to the article they were on
without even knowing it
Code: Select all
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = $_SERVER['REQUEST_URI'];
header("Location: http://{$host}{$uri}{$extra}");
exit;they return right back to it after rating it.