fsuk
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
Posts: 7972
|
 |
« 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
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: <?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['LOGIN']; ?></b> </td> </tr> <tr> <td class="login" style="text-align: left;"> <?php echo $TEXT['USERNAME']; ?>: </td> </tr> <tr> <td class="login"> <input type="text" name="username" /> </td> </tr> <tr> <td class="login" style="text-align: left;"> <?php echo $TEXT['PASSWORD']; ?>: </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['LOGIN']; ?>" style="margin-top: 3px; text-transform: uppercase;" /> </td> </tr> <tr> <td class="login"> <a href="<?php echo FORGOT_URL; ?>"><?php echo $TEXT['FORGOT_DETAILS']; ?></a> <?php if(is_numeric(FRONTEND_SIGNUP)) { ?> <a href="<?php echo SIGNUP_URL; ?>"><?php echo $TEXT['SIGNUP']; ?></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['LOGGED_IN']; ?></b> </td> </tr> <tr> <td class="login" style="padding-top: 15px; padding-bottom: 15px;"> <?php echo $TEXT['WELCOME_BACK']; ?>, <?php echo $wb->get_display_name(); ?> </td> </tr> <tr> <td class="login"> <input type="submit" name="submit" value="<?php echo $MENU['LOGOUT']; ?>" style="margin-top: 3px; text-transform: uppercase;" /> </td> </tr> <tr> <td class="login"> <a href="<?php echo PREFERENCES_URL; ?>"><?php echo $MENU['PREFERENCES']; ?></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...
|
|
|
|
|
fsuk
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
Posts: 2294
|
 |
« 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. <?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 $page = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] Ruud
|
|
|
|
|
Logged
|
Professional WebsiteBaker Solutions
|
|
|
fsuk
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: <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: <?php if(FRONTEND_LOGIN AND !$wb->is_authenticated()) { $page = 'http://'.$_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
Posts: 2294
|
 |
« 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. ......... <?php if(FRONTEND_LOGIN AND !$wb->is_authenticated()) { $page = 'http://' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?> <form name="login" action="<?php echo LOGIN_URL; ?>?redirect=<?php echo $page; ?>" method="post"> .......
Succes, Ruud
|
|
|
|
|
Logged
|
Professional WebsiteBaker Solutions
|
|
|
fsuk
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
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: <?php } elseif(FRONTEND_LOGIN AND $wb->is_authenticated()) { $page = 'http://' .$_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
Posts: 2294
|
 |
« 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
|
Professional WebsiteBaker Solutions
|
|
|
fsuk
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
Posts: 19
|
 |
« 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  ? directory/files permissions are correct...
|
|
|
|
|
Logged
|
|
|
|
mxgive
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. ......... <?php if(FRONTEND_LOGIN AND !$wb->is_authenticated()) { $page = 'http://' .$_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
|
 |
« 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
|
We are human beings - and nobody is perfect at all.
|
|
|
|