redirecting to caller page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
serap
Forum Commoner
Posts: 31
Joined: Thu Jan 15, 2004 5:10 pm

redirecting to caller page

Post by serap »

Hi everyone,

Im very new to php,

a simple question, how can I get back to the page Im calling from in this incident:
...
... \"><a href=\"cart1.php?action=add_item&id=$itemId&qty=1\">Add Item</a></font></td>\n";

I just want to stay in the same page when I call the function in cart1.php-add_item - so I do not need to go back again? (so it seems that the user stays in the same page)

reloading seems unlogical? what is usually the solution for this?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

i think what you are looking for is

Code: Select all

header(Location : "cart1.php?action=add_item&id=$itemId&qty=1");
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

On the cart.php page, check for the http referer variable and then do what infolock said with header() but using the referer address. Remember that since your using headers you can post any data to the user before you call the header() function.
serap
Forum Commoner
Posts: 31
Joined: Thu Jan 15, 2004 5:10 pm

Post by serap »

ok thanks, Ill try to continue with that...
Post Reply