Re: How know from wich page you came from

From: Date: Tue, 10 Dec 2002 13:37:35 +0000
Subject: Re: How know from wich page you came from
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127638@lists.php.net to get a copy of this message
*SOME* browsers set a referrer script name/url, and some don't, so you can't rely on it. The solution can be as simple as including the referring script as a GET variable in the URL: <a href="page.php?ref=anotherpage.php">click</a> Or, by keeping track of that sorta stuff with sessions... Whenever I *have to* know the URL of the preceding script, I take the directory, script name and query string eg dir/dir/page.php?var1=foo&var2=bah and base64 encode it (so that the get vars don't register with / affect the receiving script), and pass it to the next page: <? $this_url = "dir/dir/page.php?var1=foo&var2=bah"; $this_url = base64_encode($this_url); ?> <a href="page.php?ref=<?=$this_url?>">click</a> On page.php, I decode it all with base64_decode(), and I know exactly where the user "came from". Similar (or even smarter) stuff can be done with sessions. Justin on 11/12/02 1:20 AM, Rodrigo (php@rrb3.com) wrote: > Hi guys I need a way to know how to know from wich page the visitor > came, something like: > > I wanna put in a php file a switch to do a certain action if the visitor > came from a certain page, and something else if he came from a diferent > one, this way I could write, update, insert, delete or anything I need > from a single file. > > Thanks for any kind of input, > Rodrigo > > Justin French -------------------- http://Indent.com.au Web Development & Graphic Design --------------------

« previous php.general (#127638) next »