How to add return to previous URL after log in based on a link rather than redirect
I've got content on a page that I am hiding from users when they are not logged in. I have a button on the page for them to log in with, and I want them to return to the article they were looking at so it's easy for them to read rather than have to find it again. I've had a look through previous posts about this, and have copied a link to my page to pass the query like so:
<a href="login.php?accesscheck=<?php echo (urlencode($_SERVER["PHP_SELF"].(isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):"")));?>">Log In</a>
It just takes me straight to the user account.php rather than back to the original posting page. Here's the log in page code:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
$WA_Auth_Parameter = array(
"connection" => $conn_mrs,
"database" => $database_conn_mrs,
"tableName" => "tbl_users",
"columns" => explode($WA_Auth_Separator,"UserEmail".$WA_Auth_Separator."UserPassword"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["Log_In_group_Email"]))?$_POST["Log_In_group_Email"]:"") ."".$WA_Auth_Separator."".(WA_SHA1Encryption((isset($_POST["Log_In_group_Password"]))?$_POST["Log_In_group_Password"]:"")) .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"UserID".$WA_Auth_Separator."emailVerified"),
"sessionNames" => explode($WA_Auth_Separator,"SecurityAssist_UserID".$WA_Auth_Separator."emailVerified"),
"successRedirect" => "useraccount.php",
"failRedirect" => "login.php?failedLogin=1",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);
WA_AuthenticateUser($WA_Auth_Parameter);
}
?>
<?php
if((((isset($_SESSION["SecurityAssist_UserID"]) && $_SESSION["SecurityAssist_UserID"] != "")?"LoggedIn":"") == "")&&(((isset($_COOKIE["AutoLoginUN"]))?$_COOKIE["AutoLoginUN"]:"") != "")&&(((isset($_COOKIE["AutoLoginPWD"]))?$_COOKIE["AutoLoginPWD"]:"") != "")){
$WA_Auth_Parameter = array(
"connection" => $conn_mrs,
"database" => $database_conn_mrs,
"tableName" => "tbl_users",
"columns" => explode($WA_Auth_Separator,"UserEmail".$WA_Auth_Separator."UserPassword"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_COOKIE["AutoLoginUN"]))?$_COOKIE["AutoLoginUN"]:"") ."".$WA_Auth_Separator."".(WA_SHA1Encryption((isset($_COOKIE["AutoLoginPWD"]))?$_COOKIE["AutoLoginPWD"]:"")) .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"UserID".$WA_Auth_Separator."emailVerified"),
"sessionNames" => explode($WA_Auth_Separator,"SecurityAssist_UserID".$WA_Auth_Separator."emailVerified"),
"successRedirect" => "",
"failRedirect" => "",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);
WA_AuthenticateUser($WA_Auth_Parameter);
}
?>
What am I missing?
Thanks.