MyBB Community Forums

Full Version: Redirect user to previous page after log in
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have googled this problem all over and found tons of results but none seem to have worked. My problem is, that after I log in, it just takes me to index. However, when I log out, it returns me to the page I was previously at. This is how I want my log in to work but I can not seem to get it to do that.

Here is my welcome guest code

> <a href="http://localhost/lb/member.php?action=register">Not a member? SIGN UP!</a><br />
> <a href="http://localhost/lb/member.php?action=lostpw">Forgot Pass?</a><br />

<form action="member.php" method="post" style="padding-top: 4px;">
USERNAME:<br />

<input type="text" value="" maxlength="22" size="22" name="username" />
PASSWORD:<br />
<input type="password" value="" size="22" name="password" />

<span class="remember_me"><input checked="checked" class="checkbox" value="yes" id="quick_login_remember" name="quick_remember" type="checkbox"><label for="quick_login_remember">REMEMBER ME</label></span>
<input type="submit" name="submit" value="{$lang->login}" />
<input type="hidden" name="action" value="do_login" />
<input type="hidden" name="url" value="{$redirect_url}" />
</form>

I have
"<input type="hidden" name="url" value="{$redirect_url}" />"
so, in theory, shouldn't it work?
what version of mybb you are using... its a known bug.... and was fixed in 1.8....
I am running MyBB 1.6.15

Found a fix for it! In member.php, it was always running this code

else
{
redirect("index.php", $lang->redirect_loggedin);
}

I noticed a lot of older posts were using $_SERVER["HTTP_REFERER"] in the submit button, but in member.php it ignores all that and just does the redirect to index.php since it is bugged.
Well, change the "index.php" after the else statement to $_SERVER["HTTP_REFERER"] and surprisingly it works.