Is it possible to send a user one page back by using header? At this point i'm using meta to perform this task, but that doesn't work with other browsers than IE.
I nees something in PHP that does the same as this: javascript:history.go(-1);
Header Back
Moderator: General Moderators
Code: Select all
<?
$back = $HTTP_REFERER;
header("Location: $back");
?>For some kind og reason that didn't work? Added it in the bottom of my script, but only get this:
Code: Select all
Notice: Undefined variable: HTTP_REFERERTry
Code: Select all
$_SERVER["HTTP_REFERER"]It depends, were you using that header via a function?
If so, then you'd need to
To allow back() to access it, although note that $_SERVER['HTTP_REFERER'] is more reliable, and is superglobal.
(Asterisks used only because [ b ] isn't working properly right now.)
I might be straying a bit off-topic here, but I'm wondering: are you trying to have php code execute, but the user remain at the same page afterwards?
Code: Select all
function back(){
$back = $HTTP_REFERER;
header("Location: $back");
}
back();Code: Select all
function back(){
***global $HTTP_REFERER;***
$back = $HTTP_REFERER;
header("Location: $back");
}(Asterisks used only because [ b ] isn't working properly right now.)
I might be straying a bit off-topic here, but I'm wondering: are you trying to have php code execute, but the user remain at the same page afterwards?
It's a shopping a shopping cart. When the user clicks the delete button on a product, he's sent to a script that unsets the array containing the product, and then sends the user back to where he came from. It then looks like the page refresh and the product is gone.
I use same thing when adding a product.
I use same thing when adding a product.