timmy0320 Posted February 19, 2008 Share Posted February 19, 2008 Alright, I'm having a little issue here. I have a login system that registers through a process page. The process page checks for what form was submitted $_POST['login'], $_POST['register'], etc. or if it finds nothing it returns to the main page. session.php My session page declares the referrer variable in my sessionStart() function. Example: // set refer page for process if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; } else { $this->referrer = "/"; } process.php Once the process form checks for the appropriate one, in this case, login, then it calls to a function to which I have set. Example: // process login // if errors found client is redirected to fix information // if no errors, user is logged in function procLogin() { global $session, $function_form; // match info with user attempt to login $retval = $session->login($_POST['user'], $_POST['pass']); // login was successful if($retval) { // echo $session-referrer; header("Location: ".$session->referrer); } // login failed. else { $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $function_form->getErrorArray(); // echo $session->referrer; header("Location: ".$session->referrer); } } user.php I have a user page uses switch and case which sets the URL and loads the appropriate form. Example: case 'login': $session->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; include ("templ/user_login_body.php"); echo "<br>"; echo $_SESSION['url']; break; Now, what I want to know is when it's setting the $_SESSION['url'] it's not grabbing any of the cases, instead of the referral being user.php?do=login it is just showing user.php. Therefore, it is not going back to the case to which I need it to (which would be the login case). Such as the user_login_body contains an (if $session->logged_in) statement that refers to the main user panel } else { it reports any errors. Is there a simple way of doing this? My guess is to change the code in each case that contains $session->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; to add on at the end of it the "?do=(case)" manually but there's got to be some type of way to do it without having to do that. Link to comment https://forums.phpfreaks.com/topic/91825-referrer-page/ Share on other sites More sharing options...
uniflare Posted February 19, 2008 Share Posted February 19, 2008 instead of $_SERVER['PHP_SELF']; try using $_SERVER['REQUEST_URI']; Link to comment https://forums.phpfreaks.com/topic/91825-referrer-page/#findComment-470307 Share on other sites More sharing options...
timmy0320 Posted February 19, 2008 Author Share Posted February 19, 2008 instead of $_SERVER['PHP_SELF']; try using $_SERVER['REQUEST_URI']; Hey dude, you're the man! Guess I should learn more of my $_SERVER variables eh? Link to comment https://forums.phpfreaks.com/topic/91825-referrer-page/#findComment-470309 Share on other sites More sharing options...
uniflare Posted February 19, 2008 Share Posted February 19, 2008 hehe np, for more information on global variables see http://uk2.php.net/manual/en/reserved.variables.php#reserved.variables.server Link to comment https://forums.phpfreaks.com/topic/91825-referrer-page/#findComment-470312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.