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
sarris
Forum Contributor
Posts: 137 Joined: Mon Dec 04, 2006 2:44 pm
Post
by sarris » Wed Feb 28, 2007 9:30 am
Hi there...Is there any way to redirect a page (php page) to the previous one, as if the user clicked the BACK button on his browser?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 28, 2007 9:44 am
The data isn't reliably set, but there is $_SERVER['HTTP_REFERER']
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Feb 28, 2007 10:00 am
Javascript
Code: Select all
<a href="javascript:history.go(-1)">GO BACK</a>
PHP
Code: Select all
$PrevURL = $_SESSION['GoBack'];
header("Location: ".$PrevURL);
But in all your pages you go to include a
$_SESSION['GoBack'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
sarris
Forum Contributor
Posts: 137 Joined: Mon Dec 04, 2006 2:44 pm
Post
by sarris » Wed Feb 28, 2007 10:31 am
Code: Select all
php:
$PrevURL = $_SESSION['GoBack'];
header("Location: ".$PrevURL);
used that and got this errror
Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/houseonmap.gr/httpdocs/removeShortList.php:28) in /home/httpd/vhosts/houseonmap.gr/httpdocs/removeShortList.php on line 30
i put this line
Code: Select all
$_SESSION['GoBack'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
to the involved pages.
Is it REQUEST_URI? or REQUEST_URL?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 28, 2007 10:35 am
"headers already sent" has been talked about so much that very few people will rehash the fix.
As for your second question.. take a look in $_SERVER for yourself .. or search the boards for "getURL"
sarris
Forum Contributor
Posts: 137 Joined: Mon Dec 04, 2006 2:44 pm
Post
by sarris » Wed Feb 28, 2007 1:02 pm
"headers already sent" has been talked about so much that very few people will rehash the fix
which means? no solution?
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Wed Feb 28, 2007 1:15 pm
if it's been talked about on the boards before, generally you should be able to find it by
searching ...
sarris
Forum Contributor
Posts: 137 Joined: Mon Dec 04, 2006 2:44 pm
Post
by sarris » Wed Feb 28, 2007 3:40 pm
ok. will try to find the solution.
another question. is it true that redirection with javascript may cause your page to be removed from search engines?
sarris
Forum Contributor
Posts: 137 Joined: Mon Dec 04, 2006 2:44 pm
Post
by sarris » Wed Feb 28, 2007 4:34 pm
i deleted any previous echo commands and all works fine.Thanks anyway