MyBB Community Forums

Full Version: Problem - Custom quick login always redirect to index page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I created custom quick login so users don't need to click login link to show username textbox and password. But there's a problem here. When users read a thread and then they sign in using my quick login, they always redirected to index page.

For example users read thread: http://forum.komputer-id.com/Thread-Hell...d=12#pid12
And then they login, They will be redirected to index. I want it redirected to current page (the thread are being read by them).

It's my script:
<form method="post" action="member.php">
<input name="action" type="hidden" value="do_login"/>
<input name="url" type="hidden" value="{$mybb->settings['bburl']}"/> 
<input name="quick_login" type="hidden" value="1"/> 
<input name="quick_username" id="quick_login_username" type="text" placeholder="{$lang->login_username}" class="textbox text_UserPass"/>&nbsp;
<input name="quick_password" id="quick_login_password" type="password" placeholder="{$lang->login_password}" class="textbox text_UserPass"/>&nbsp;<input name="submit" type="submit" value="{$lang->welcome_login}" class="mylogin_button">&nbsp;<input name="reg_button" type="button" value="{$lang->welcome_register}" class="register_button" onclick="window.location='{$mybb->settings['bburl']}/member.php?action=register'"/><span class="remember_me"><input name="quick_remember" id="quick_login_remember" type="checkbox" value="yes" class="checkbox"/><label for="quick_login_remember"> {$lang->remember_me}</label></span>
<a href="{$mybb->settings['bburl']}/member.php?action=lostpw" class="lost_password" rel="nofollow">{$lang->lost_password}</a>
</form>

I know the problem was here:
<input name="url" type="hidden" value="{$mybb->settings['bburl']}"/> 

I know {$mybb->settings['bburl']} is means index page of forum. But I don't know script for current page. Can you tell me html script for current page? So it can make my quicklogin be redirected to page came from.

You can access my forum http://forum.komputer-id.com using username: user123 password: user123.
Try to read a thread and then sign in using username and password I've given. You always redirected to index page
Try adding this and editing the line you have hightlighted

<script type="text/javascript">
 window.onload = function()
 {
     var url = document.getElementById('redirectURLTextbox1');
     if (url)
     {
      url.value = window.location;
     }
 }
 </script>

<input type='hidden' name='action' value='do_login' />
<input type="hidden" name="url" value="{$redirect_url}" id="redirectURLTextbox1" />
Great!. Thank you very much Leefish. It works.
I will mark this thread as solved
Here is a php version that will work even if javascript is disabled:

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

 return $pageURL;
}


// Use the above function
$return_url = curPageURL();
// Your example line
<input name="url" type="hidden" value="<?php echo $return_url ?>"/> 

?> 

I've been using that function for a while and it seems to work well...


#
The original version can handle htt p://mybb.com:8765/newreply.php?tid=133000&processed=1 if (for some reason) you want to serve http from port 8765 Toungue
I am very new to MyBB and not all that savvy with php and the like.

What I need to have is a log-in page sitting before the default index page. I need to have only the blank log-in fields visible to members and non-members unlike. Upon successful logging in the member will then be moved to their default index page.

Creating an html log-in page would be awkward in having the member log in twice.

Any and all newbie solutions would be appreciated. Though complicated for me would something like what is being discussed in this thread do what I am in need of doing?






(2013-01-19, 07:01 AM)seeker Wrote: [ -> ]Here is a php version that will work even if javascript is disabled:

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

 return $pageURL;
}



// Use the above function
$return_url = curPageURL();
// Your example line
<input name="url" type="hidden" value="<?php echo $return_url ?>"/> 

?> 

I've been using that function for a while and it seems to work well...


#
The original version can handle htt p://mybb.com:8765/newreply.php?tid=133000&processed=1 if (for some reason) you want to serve http from port 8765 Toungue