Welcome, Guest. Please login or register.
Did you miss your activation email?
July 29, 2014, 01:42:41 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
179341 Posts in 24552 Topics by 6447 Members
Latest Member: act5860
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Login Redirect - Is it possible to stay on the same page?  (Read 10640 times)
fsuk

Offline Offline

Posts: 127



« on: July 08, 2008, 12:59:49 PM »

When a user logs in to my site they are redirected to the home page. Is it possible to modiffy class.login.php so that it stays on the same page as the one they logged in on?
Logged

You say deviant like its a bad thing...
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 8244



WWW
« Reply #1 on: July 08, 2008, 01:34:04 PM »

Hello,

don't modify the class.login.php, please only modify the login call in your template. Can easily be done by adding the redirect to the login action.

Matthias
Logged
fsuk

Offline Offline

Posts: 127



« Reply #2 on: July 08, 2008, 01:40:29 PM »

What is this redirect to login action. How do i implement it?

Current code in template for login menu:
Code:
<?php
        
if(FRONTEND_LOGIN AND !$wb->is_authenticated()) {
        
?>

        <form name="login" action="<?php echo LOGIN_URL?>" method="post">
           
            <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" style="margin-top: 10px;">
            <tr>
                <td class="border">
                    <img src="<?php echo TEMPLATE_DIR?>/menu_top.gif" border="0" alt="" />
                </td>
            </tr>
            <tr>
                <td class="login" style="text-transform: uppercase;">
                    <b><?php echo $TEXT[&#39;LOGIN&#39;]; ?></b>
                </td>
            </tr>
            <tr>
                <td class="login" style="text-align: left;">
                    <?php echo $TEXT[&#39;USERNAME&#39;]; ?>:
                </td>
            </tr>
            <tr>
                <td class="login">
                    <input type="text" name="username" />
                </td>
            </tr>
            <tr>
                <td class="login" style="text-align: left;">
                    <?php echo $TEXT[&#39;PASSWORD&#39;]; ?>:
                </td>
            </tr>
            <tr>
                <td class="login">
                    <input type="password" name="password" />
                </td>
            </tr>
            <tr>
                <td class="login">
                    <input type="submit" name="submit" value="<?php echo $TEXT[&#39;LOGIN&#39;]; ?>" style="margin-top: 3px; text-transform: uppercase;" />
                </td>
            </tr>
            <tr>
                <td class="login">
                    <a href="<?php echo FORGOT_URL?>"><?php echo $TEXT[&#39;FORGOT_DETAILS&#39;]; ?></a>
                    <?php if(is_numeric(FRONTEND_SIGNUP)) { ?>
                        <a href="<?php echo SIGNUP_URL?>"><?php echo $TEXT[&#39;SIGNUP&#39;]; ?></a>
                    <?php ?>
                </td>
            </tr>
            <tr>
                <td class="border">
                    <img src="<?php echo TEMPLATE_DIR?>/menu_bottom.gif" border="0" alt="" />
                </td>
            </tr>
            </table>
       
        </form>
        <?php
        
} elseif(FRONTEND_LOGIN AND $wb->is_authenticated()) {
        
?>

        <form name="logout" action="<?php echo LOGOUT_URL?>" method="post">
           
            <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" style="margin-top: 10px;">
            <tr>
                <td class="border">
                    <img src="<?php echo TEMPLATE_DIR?>/menu_top.gif" border="0" alt="" />
                </td>
            </tr>
            <tr>
                <td class="login" style="text-transform: uppercase;">
                    <b><?php echo $TEXT[&#39;LOGGED_IN&#39;]; ?></b>
                </td>
            </tr>
            <tr>
                <td class="login" style="padding-top: 15px; padding-bottom: 15px;">
                    <?php echo $TEXT[&#39;WELCOME_BACK&#39;]; ?>, <?php echo $wb->get_display_name(); ?>
                </td>
            </tr>
            <tr>
                <td class="login">
                    <input type="submit" name="submit" value="<?php echo $MENU[&#39;LOGOUT&#39;]; ?>" style="margin-top: 3px; text-transform: uppercase;" />
                </td>
            </tr>
            <tr>
                <td class="login">
                    <a href="<?php echo PREFERENCES_URL?>"><?php echo $MENU[&#39;PREFERENCES&#39;]; ?></a>
                </td>
            </tr>
            <tr>
                <td class="border">
                    <img src="<?php echo TEMPLATE_DIR?>/menu_bottom.gif" border="0" alt="" />
                </td>
            </tr>
            </table>
       
        </form>
        <?php
        
}
        
?>
Logged

You say deviant like its a bad thing...
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 8244



WWW
« Reply #3 on: July 08, 2008, 02:43:17 PM »

Hello,

a quick search in the forum for "redirect" gives you all the answers you need. You also will find this:

http://www.websitebaker2.org/forum/index.php/topic,9801.msg57796.html#msg57796

And please for the future, before asking a question, search the forum. Thanks

Matthias
Logged
fsuk

Offline Offline

Posts: 127



« Reply #4 on: July 08, 2008, 02:49:33 PM »

I think you miss-understand.

I dont want the user to be redirected to a login page.

When the user is on, for example, the events page and there is a login box underneath the menu they can login there. But once they click the login button and are logged in they are redirected to the home page, they do not remain on the same page.

What i want is for the user to click login on whatever page they may be on and for them to be logged in and remain on the same page.

Thanks for you help
Logged

You say deviant like its a bad thing...
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2952



WWW
« Reply #5 on: July 08, 2008, 11:15:55 PM »

If you read the thread that Matthias pointed. The last line shows what to do.

Code:
<?php echo LOGIN_URL?>/account/login.php?redirect=http://www.yourdomain.com/pages/redirectpage.php

You should be able to get the redirect url with something like this

Code:
$page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]

Ruud
Logged

dev4me.nl - Professional WebsiteBaker Solutions
fsuk

Offline Offline

Posts: 127



« Reply #6 on: July 09, 2008, 01:12:06 AM »

I dont have that exact text in my index.php of my template the closest is:

Code:
<form name="login" action="<?php echo LOGIN_URL?>" method="post">

See above for the full login/logout form code.

I've tried this but it has no effect:

Code:
       <?php
        
if(FRONTEND_LOGIN AND !$wb->is_authenticated()) {
        
$page = &#39;http://&#39;.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]
        
?>

        <form name="login" action="<?php echo LOGIN_URL?>?redirect=<?php $page?>" method="post">
           
Logged

You say deviant like its a bad thing...
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2952



WWW
« Reply #7 on: July 09, 2008, 09:05:59 AM »

There are a few php buggies in the code.

$page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] ;
and
<form name="login" action="<?php echo LOGIN_URL; ?>?redirect=<?php echo $page; ?>" method="post">

The code below works on my testserver.

Code:
.........
<?php
    
if(FRONTEND_LOGIN AND !$wb->is_authenticated()) {
        
$page = &#39;http://&#39; .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        
?>

        <form name="login" action="<?php echo LOGIN_URL?>?redirect=<?php echo $page?>" method="post">
.......

Succes,

Ruud
Logged

dev4me.nl - Professional WebsiteBaker Solutions
fsuk

Offline Offline

Posts: 127



« Reply #8 on: July 09, 2008, 09:20:05 AM »

ok that works great. Thanks.

Im still quite new to php, but im getting there slowley.

Thanks for your help guys.
Logged

You say deviant like its a bad thing...
fsuk

Offline Offline

Posts: 127



« Reply #9 on: July 09, 2008, 11:11:49 AM »

Ive just tried applying it to the logout and it dosn't work:

Code:
       <?php
        
} elseif(FRONTEND_LOGIN AND $wb->is_authenticated()) {
        
$page = &#39;http://&#39; .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        
?>

        <form name="logout" action="<?php echo LOGOUT_URL?>?redirect=<?php echo $page?>" method="post">

Is there anyway to apply it to the logout?
Logged

You say deviant like its a bad thing...
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2952



WWW
« Reply #10 on: July 09, 2008, 11:26:53 AM »

No, not without modifying one of the core files.

If you do that, any upgrade to a next version will at least undo your changes.

Ruud
Logged

dev4me.nl - Professional WebsiteBaker Solutions
fsuk

Offline Offline

Posts: 127



« Reply #11 on: July 09, 2008, 11:28:58 AM »

Ok well i suppose i can leave the logout redirect.

Thanks for your help
Logged

You say deviant like its a bad thing...
xoanon

Offline Offline

Posts: 34


« Reply #12 on: November 21, 2008, 05:43:42 PM »

I just implemented the proposed code and immediately I get permission error message as follows

>>
You don't have permission to access /wb/account/login.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

once the redirection code is removed everything works fine !!!!!!!!!

Any Ideas why Huh?    directory/files permissions are correct...
Logged
mxgive

Offline Offline

Posts: 1


« Reply #13 on: July 09, 2009, 01:23:09 PM »

There are a few php buggies in the code.

$page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] ;
and
<form name="login" action="<?php echo LOGIN_URL; ?>?redirect=<?php echo $page; ?>" method="post">

The code below works on my testserver.

Code:
.........
<?php
    
if(FRONTEND_LOGIN AND !$wb->is_authenticated()) {
        
$page = &#39;http://&#39; .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        
?>

        <form name="login" action="<?php echo LOGIN_URL?>?redirect=<?php echo $page?>" method="post">
.......

Succes,

Ruud

If this post is applicable to SMF 1.1.8, pls in which files will I find those codes above
Logged
Luisehahne
Board Member
WebsiteBaker Support Members

Offline Offline

Posts: 3702



WWW
« Reply #14 on: July 09, 2009, 09:22:34 PM »

until yet i don't test it, what happens on web server with mod_security?

Dietmar
Logged

Eric T. Hansen, amerikanischer Buchautor „Nörgeln des Deutschen größte Lust"
"Sie haben das Reccht zu schweigen, Alles was Sie sagen kann gegen Sie verwendet werden"
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!