Soldato
- Joined
- 12 Feb 2006
- Posts
- 17,720
- Location
- Surrey
i have always managed rto have this working, now i go back to add more to the code and it now doesn't work and i have no clue why.
basically as all my pages are on my machine i decided that every page would include one page straight away by using $_SERVER['DOCUMENT_ROOT'] which defines a variable called $root. this variable defines the path on my machine to get to the root folder for the site i'm working on which is deeper then htdocs.
for the user login page i orignally had it only redirect the user to one specific page if already logged in and after logging in take the user to that page whicjh was defined as $root . "member/pagetogoto.php" this worked until i added the ability to choose either previous page, member page or hmoe page.
to go to previous page i use $_SERVER["REQUEST_URI"] which isn't the previous page but curent but to the user it looks like previos page. this keeps all the variables in the url so returning to what the page should be as before.
this works when the user chooses the previous page when logging in however when choosing home page or member page as this uses the $root variable the page is never redirected only refreshed. at first i though i may have needed to use global $root as perhaps i was too deep in the code to use $root but then the first thing the page does is check if logged in and if so redirect to $root . "memberpage.php which doesn't work no more either.
so why might the $root variable not be working when using header location to redirect? if i echo $root out instead of redirect then it echo's as expected so really stuck
sorry for long post but firgured i'd explain the whole situation
thanks for any help
basically as all my pages are on my machine i decided that every page would include one page straight away by using $_SERVER['DOCUMENT_ROOT'] which defines a variable called $root. this variable defines the path on my machine to get to the root folder for the site i'm working on which is deeper then htdocs.
for the user login page i orignally had it only redirect the user to one specific page if already logged in and after logging in take the user to that page whicjh was defined as $root . "member/pagetogoto.php" this worked until i added the ability to choose either previous page, member page or hmoe page.
to go to previous page i use $_SERVER["REQUEST_URI"] which isn't the previous page but curent but to the user it looks like previos page. this keeps all the variables in the url so returning to what the page should be as before.
this works when the user chooses the previous page when logging in however when choosing home page or member page as this uses the $root variable the page is never redirected only refreshed. at first i though i may have needed to use global $root as perhaps i was too deep in the code to use $root but then the first thing the page does is check if logged in and if so redirect to $root . "memberpage.php which doesn't work no more either.
so why might the $root variable not be working when using header location to redirect? if i echo $root out instead of redirect then it echo's as expected so really stuck
sorry for long post but firgured i'd explain the whole situation
thanks for any help
Last edited: