Home
Homepage
Downloads
Downloads
Forums
Forums
Your Account
Il Tuo Account
IngegneriConLePalle.com - Il sito degli Studenti della Facoltà di Ingegneria di Forlì
Promotions


Online Chat
Vuoi cambiar Nome?!
/n tuonome cambia nick
Scegli la Tua Chat 
MobileFissa
PopupOff

Menu
 Homepage
 Utenti
 Il tuo profilo
 Lista Membri
 Blog Utenti
 Firma il Guestbook!
 Contatta Web Master
 Passaparola!!!!
 Community
 Galleria Foto
 Salagiochi
 Forums
 Messaggi Privati
 Cruciverba
 Sudoku
 WebChat
 Calendario Eventi
 Torneo Fantacalcio
 Documenti
 Risorse
 Downloads
 Loghi x Cellulari
 Web Links
 Barzellette
 Cerca nel Sito
 Documenti
 Argomenti
 News
 Aggiungi News
 Digital-Sat News
 AvantGo
 Servizi
 Previsioni Meteo
 Elenco Telefonico
 Video Musicali
 Radio Streaming
 Serata in TV
 Stradario d'Italia
 GoogleMaps
 Utilitą
 Php-Nuke Tools
 GUIstuff+
 Multi Search Engine
 Codice Fiscale
 Underground Search
 Submit Engines
 Open Directory
 PHP-Nuke HOWTO
 Statistiche
 Statistiche del Sito
 Analysis
 Top 10
 Inverno 2005
 Bollettino Neve
 WebCam Neve
 Site Map
 RSS Articoli 0.91
 RSS Articoli 2.0
 RSS Downloads 0.91
 RSS Downloads 2.0
 RSS Links 0.91
 RSS Links 2.0
 RSS Forums 0.91
 RSS Forums 2.0
 RSS Calendario 0.91
 RSS Calendario 2.0
 ATOM Articoli 0.3
 Spambot Killer

Promotions

Security
_AB_WARNED
We have caught 1656 shameful hackers.

NukeSentinel™ 2.5.17

How to redirect users to Login and back

18.6.3. How to redirect users to Login and back

We have already seen how to redirect users to the Login page (Section 18.2.1), to the Homepage (Section 18.6.1) and to the Forum profile from the Your Info profile (Section 18.6.2). Finally, it is time that we consider the general redirection problem:

You are using some module, say an eCommerce module like the Emporium Shopping Cart (Section 8.3.14), and at some point you need to ask the user to login (if not already done) to finish off the order. You would like to redirect the user to the Login screen (Figure 3-28), then bring him back where he was to continue.

This is already implemented in PHP-Nuke at some places, like the Private Messages part of the Your Account module: in the forums for example, if you aren't logged in, you see the link 'Log in to check your private messages', which when clicked on it, takes you to Your Account (address line becomes : http://www.yoursite.com/modules.php?name=Your_Account&redirect=privmsg&folder=inbox), and upon login in, you get taken back to PMs.

To accomplish this from an arbitrary module, that serves as the starting point for the redirection, open that module's code and find the place where the redirection has to happen. Initiate the redirection with the following two lines:

$redirect = $module_name;
<a href=\"modules.php?name=Your_Account&redirect=$redirect\">CLICK HERE TO LOGIN</a>

The value of $redirect is what you will key off in the next step. In this example we use the module name as the key that will point the way back, but you can use anything, as long as you know how to use it later, to trace your way back with the right link.

Now go to modules/Your_Account/index.php and look for the following code in the login() function:

if ($pm_login != "") {
            Header("Location: modules.php?name=Private_Messages&file=index&folder=inbox");
            exit;
            }

Add the following after it:

if ($redirect == "XXXXXXXXX"){
        Header("Location: modules.php?name=YYYYYYYYY");
        exit;
        }

where XXXXXXXXX is the value of $redirect from the first step and YYYYYYYY is the name of the module you want them dumped into after login.

You might think that we are done by now, but there is a caveat: the above will work as long as they log in correctly on the first try. If they make a mistake and have to try a second or more times, they will get dumped in Your Account, after they log in successfully, not in the module they came from. This is also true for the Private Messages example above.

To fix this, find the following code in Your_Account\index.php at the bottom of the login function.

} else {
   Header("Location: modules.php?name=$module_name&stop=1");
    }

and change it to:

} else {
     Header("Location: modules.php?name=$module_name&stop=1&redirect=$redirect");
    }

Then it will redirect even if they log in incorrectly the first time. See How to redirect.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

.:: WebMaster Ing. Francesco Feruzzi :: ©2005 IngegneriConLePalle.com :: Regolamento ::.
Generazione pagina: 0.22 Secondi
Creative Commons License
Eccetto dove diversamente specificato, i contenuti di questo sito sono rilasciati sotto Licenza Creative Commons Attribuzione 2.5.

Add to Google
SEO Stats powered by MyPagerank.Net