karenn1 Posted June 11, 2007 Share Posted June 11, 2007 I have a website that caters for people from different areas in the city. Every area has it's own folder and unique pages. I want all of these people to log into one common members area. This prevents having several members area folders as well. My problem is when you log out, I've got it hard coded to go to a specified page. How can I change that so that it redirects to the folder the person logged in from? Is there some sort of ROOT or SERVER ADDRESS code I can use? I've seen it before but I don't know how to use it. Any help would be appreciated. Thanks, Karen Quote Link to comment https://forums.phpfreaks.com/topic/55091-dynamic-redirect/ Share on other sites More sharing options...
Psycho Posted June 11, 2007 Share Posted June 11, 2007 Yes, absolutely: http://us.php.net/reserved.variables You would want either QUERY_STRING or DOCUMENT_ROOT However, you could also use cookies or session variables as well. Quote Link to comment https://forums.phpfreaks.com/topic/55091-dynamic-redirect/#findComment-272367 Share on other sites More sharing options...
smc Posted June 11, 2007 Share Posted June 11, 2007 Well as I understand you what I would do is keep a running track of what page they are on. Say I'm in my domain and I'm on a page "page.php" in the directory "root/directory/" If I run this variable $_SERVER['PHP_SELF'] it will return /directory/page.php. Knowing that you can use a session to keep a running tab of what page they are on. Using something like: session_start(); $_SESSION['referring_page'] = $_SERVER['PHP_SELF']; Then on your redirect just use header( 'location: ' . $_SESSION['referring_page'] ); Assuming you already declared session_start(); in the login script. I would recommend against using REFERRER to track the page as it is often untrustworthy. Quote Link to comment https://forums.phpfreaks.com/topic/55091-dynamic-redirect/#findComment-272443 Share on other sites More sharing options...
karenn1 Posted June 13, 2007 Author Share Posted June 13, 2007 Hey guys! Thanks for the replies. I will give this a try. Karen Quote Link to comment https://forums.phpfreaks.com/topic/55091-dynamic-redirect/#findComment-273880 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.