philbs777 Posted March 9, 2012 Share Posted March 9, 2012 I have a log in form, once filled out if successfully logged in, it should go back to the same page url including the url variables. It works, but does not carry the url varables (?barnid=123) with it. <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; $MM_redirectLoginFailed = "login_fail.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_admin, $admin); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $admin) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrlx']) && false) { $XXMM_redirectLoginSuccessXX = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> What could i be doing wrong? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 9, 2012 Share Posted March 9, 2012 Start by changing header to echo and make sure the value is what it should be. Quote Link to comment Share on other sites More sharing options...
q11we Posted March 9, 2012 Share Posted March 9, 2012 If the from user submits his username and password is the same page with php code, provide $_SERVER[QUERY_STRING] in action attribute of form. <form method="post" action="<?php echo $_SERVER[php_SELF].'?'.$_SERVER[QUERY_STRING]; ?>"> 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.