close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to add return to previous URL after log in based on a link rather than redirect

Thread began 9/09/2013 3:36 am by mrs | Last modified 9/09/2013 2:09 pm by Jason Byrnes | 1792 views | 3 replies |

mrs

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.

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

mrs

Sorry for the delay in responding. Had a meeting. See below and files attached.

If I use the link 'Log in' to check access and pass the URL, then the got to previous URL doesn't work, but if I try to access a page that is protected, then I get redirected to login.php and then back to the initial URL as expected. I've obviously missed something minor in my login link I think, but don't know what.

Thank you.

PS... just a thought, in the detail page I've attached, do I need to reference the security assist helper?

Sign in to reply to this post

Jason ByrnesWebAssist

on the login page, i changed the action of the form to:
action="<?php echo(htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)."?".$_SERVER["QUERY_STRING"]); ?>"


this corrected the problem.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...