Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.1.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=20)
-   -   Redirect to Previous Page after Login/Logout (http://www.mysidiaadoptables.com/forum/showthread.php?t=1784)

fadillzzz 01-23-2011 05:06 AM

Redirect to Previous Page after Login/Logout
 
This is just a simple modification to rediret a user to the previous page they were viewing after login/logout.

NOTE:Please make a backup of your files before installing this mod!

Let's start with login.php

1.Open your login.php and go to line 144 and add this code
PHP Code:

header("Location: ".$_SERVER['HTTP_REFERER']); 

What we just did will redirect the users to the previous page immediately. So, the users won't see the login message that they usually see. If you still wanted to show them that message, add a timer.

If you want to add a timer, instead of using the above code use this instead
PHP Code:

header("Refresh: 2; URL=".$_SERVER['HTTP_REFERER']); 

Change the number 2 to how many seconds you want before the page redirect the users to the previous page

Move on to logout.php
2. Now to redirect the logout process. Open your logout.php, on line 80 put this code (same as above)
PHP Code:

header("Location: ".$_SERVER['HTTP_REFERER']); 

Again, if you want to add a timer so that the users still see the usual message use this code and change the number 2 to the number of how many seconds you want the users to wait before they get redirected
PHP Code:

header("Refresh: 2; URL=".$_SERVER['HTTP_REFERER']); 

Congrats! Now you'll save your users from their laziness of clicking! (well, not really actually)

You're not limited to this, for example if you wanted to redirect the users to the index page after logging out you can use this code
PHP Code:

header("Location: http://".$domain.$scriptpath); 

and if you want to add a timer use this
PHP Code:

header("Refresh: 2; URL=http://".$domain.$scriptpath); 


Rozel 01-29-2011 06:49 PM

This seems awesome, but how do I know where to put the code? You said line 144, but I don't know how to tell which is line 144 using the 000webhost editor. :S

fadillzzz 01-29-2011 07:11 PM

Use a PHP editor, you can use notepad++ if you want

Kaeliah 01-29-2011 09:24 PM

Just as a general note, using line numbers as a guide to put the code can be very faulty. If users have added other mods beforehand the lines will be messed up for them. I usually use a chunk of code that comes before or after the place the new code should go. :smile:

fadillzzz 01-29-2011 09:58 PM

Ok, I'll keep that in mind for another tutorial

Rozel 01-29-2011 10:38 PM

Ah, yeah, I do remember I had Notepad++. I'll use that, thanks. :o

Tony 02-02-2011 05:24 PM

On some hosts, the header redirect will be funky, especially if you have an email system somewhere. For an alternative, you can use the following.

PHP Code:

echo '<meta http-equiv="refresh" content="2;url=".$domain.$scriptpath">'



All times are GMT -5. The time now is 04:56 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.