Hello, I've got some problems with $_SERVER['HTTP_REFERRER'] function. I need to do something like this: I have 3 pages, 1.index.php 2. login.php 3. member.php (need login to access) If any one tries to go from index.php to member.php without login, the member.php will redirect the user to login.php, and after successful login, the user will be redirected to the member.php. I need to solve this problem by using the referer function. Can any one help me in this regard? Solution will be highly appreciated.
The referrer is sent by the browser, and not all browsers send it by default. Plus it can be easily modified. That means you shouldn't rely on it. Work with sessions instead. Start a session in login, and check for it in member.php. If there's none, or it's not valid, throw an error.
You should do this with session when you loggin you create a session['loggedin'] which you will want to put, if ($_SESSION['LOGGEDIN'] != TRUE) { echo "you are not authorized"; exit;} thats a better safer way.
Thanks for the suggestions. I used session for login, but after successful login, how can i send the member to the page where he wanted to go before login?