mjurmann Posted July 12, 2007 Share Posted July 12, 2007 Hello. Every time I add an update to a user's account on my website, I have an auto e-mail sent out to the user. It is formatted with HTML and includes a hyperlink. This hyperlink will be in the form of http:/www.domainname.com/page.php?variable . Once they click on it, they will be forced to login to the site since that page is restricted to clients only. Once they login in, I want them to be forwarded to that initial link that they clicked on. Instead, they are forwarded to http://www.domainname.com/page.php - The variable seems to get cut off. Can someone please assist me with keeping the url intact including the variable at the end? Here is my code: <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); $_SESSION['MM_Username'] = NULL; } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['Email'])) { $loginUsername=$_POST['Email']; $password=$_POST['Password']; $MM_fldUserAuthorization = "authorized"; $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; // I think the problem might be here $MM_redirectLoginFailed = "login-failed.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_Chromatic, $Chromatic); $LoginRS__query=sprintf("SELECT email, password, authorized FROM clients WHERE email='%s' AND password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $Chromatic) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'authorized'); //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Quote Link to comment Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 Can someone please help me? Quote Link to comment Share on other sites More sharing options...
lococobra Posted July 13, 2007 Share Posted July 13, 2007 Your code is very confusing... and you didn't give very much information about what your variables are for. First of all, I notice that you declare <?php $loginFormAction = $_SERVER['PHP_SELF']; ?> Then never use that information again. Some of your stuff seems a bit... strange to me <?php if(isset($_SESSION['PrevUrl']) && false) ?> Are you saying... if that session variable exists, and false exists? I assume you meant to say <?php if(isset($_SESSION['PrevUrl'])===FALSE) ?> Seems to me that a way to simplify this whole process is to basicly say... If login was successful then gotoLocation = success_url If login failed then gotoLocation = failed_url That way you can get rid of one of your header() lines. That's pretty much the best I can do, it would take me a lot more time to actually figure out what your code is doing... but it seems to need some work. Or... I'm just a novice at php and I have no idea what I'm talking about Quote Link to comment Share on other sites More sharing options...
mjurmann Posted July 13, 2007 Author Share Posted July 13, 2007 I appreciate the response, however, it didn't fix the problem. Now my question is quite simple: Is it possible to take a variable from a URL such as admin-home.php?id=001 where 001 is the data from the id variable and then perform a series of conditional statements before the <head></head> tags. It seems that when I try to $_GET['id'] in the area before the <head> </head> tags the id variable is null. However, when I echo that same variable out in the body, the id echoes out correctly. Simple question...anyone? Thanks so much Quote Link to comment Share on other sites More sharing options...
lococobra Posted July 13, 2007 Share Posted July 13, 2007 You can retrieve POST/GET variables at any point in a script. They are effectively loaded before your code starts running. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.