langenf Posted January 10, 2009 Share Posted January 10, 2009 hi, im making an app that needs users to be logged in inorder to use it. The file structure of the app is like this. root /app //includes includes is in tha app folder which is in the root. includes folder has a file that login_check and moves the redirects the to app/index.php when the user is not logged in like this header("Location:../index.php?mesagge=$mesagge"). It works as expected within the application. Say for example when the user clicks the logout button or when user enters a wrong password trying to login . But when i try to access a file in the app folder say app/show_articles.php without logging in, it redirects the user to root folder index.php. Can you please say what is wrong here? Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/ Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 it could be the path is no longer correct from their current location as you using a relative path. Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-733952 Share on other sites More sharing options...
langenf Posted January 10, 2009 Author Share Posted January 10, 2009 it could be the path is no longer correct from their current location as you using a relative path. I dont want to use absolute path since relative paths are usually better. If it cannot be done with relative path, im willing to use absolute paths though Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-733953 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 as a test try having the header redirect on the page then if it redirects to the right place you know it's the paths causing it. Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-733965 Share on other sites More sharing options...
langenf Posted January 10, 2009 Author Share Posted January 10, 2009 as a test try having the header redirect on the page then if it redirects to the right place you know it's the paths causing it. sorry, i dont understand. you mean ("Location:http:/server/app/index.php?mesagge=$mesagge") like this? Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-734001 Share on other sites More sharing options...
nuttycoder Posted January 10, 2009 Share Posted January 10, 2009 what i mean to test the header on a page you want the user to have to login first you could put the header code directly on that page with a relative path from that page in the header. Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-734003 Share on other sites More sharing options...
abdfahim Posted January 10, 2009 Share Posted January 10, 2009 I think the better procedure would be whenever use anylinnk, always use "/" as root .... for example header("location: /page1.php"); header("location: /app/page1.php"); header("location: /app/includes/page1.php"); etc ... Link to comment https://forums.phpfreaks.com/topic/140262-redirection-not-is-consistent/#findComment-734010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.