Alexhoward Posted March 15, 2009 Share Posted March 15, 2009 Hi Guys, wondering if anyone could help me out with this...? I have a member area (amongst others) that require login to access. thing is if you are not logged in it bounces you back to the login page when the user logs in i would then like to take them back to where they were trying to get to i'm using the header function but can't seem to get it to work with $_SERVER['HTTP_REFERER'] could anyone tell me if this is possible and if so how? Thanks in advance! Add Some Music http://www.addsomemusic.co.uk Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/ Share on other sites More sharing options...
ram4nd Posted March 15, 2009 Share Posted March 15, 2009 use <?php header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?> Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-785338 Share on other sites More sharing options...
Alexhoward Posted March 15, 2009 Author Share Posted March 15, 2009 hi, yes i know how to do it manually, however, i'd like to do it with $_SERVER['HTTP_REFERER'], so they are directed back to where they cam from Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-785424 Share on other sites More sharing options...
Alexhoward Posted March 16, 2009 Author Share Posted March 16, 2009 can anyone help me out with this..? Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-785920 Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 store the value into session first: <?php session_start(); if(!$_SESSION['username']){ //Not logged in $_SESSION['last_page'] = $_SERVER['REQUEST_URI']; header('Location: login.php'); exit; } ?> <?php session_start(); if($_POST['user']){ //Validate user here $page = $_SESSION['last_page'] ? $_SESSION['last_page'] : 'home.php'; unset($_SESSION['last_page']); header('Location: '.$page); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-785925 Share on other sites More sharing options...
Alexhoward Posted March 16, 2009 Author Share Posted March 16, 2009 Hi, Thanks for the reply, It looks like i have to do a if they came from here go here kind of thing, isn't there just a header('Location: '.$_SERVER['REQUEST_URI']); sort of thing i can do...? Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-786007 Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 It looks like i have to do a if they came from here go here kind of thing, huh? Link to comment https://forums.phpfreaks.com/topic/149544-redirect-by-http_referer/#findComment-786011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.