Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

[Solved ??] conditional redirection after login/logout

Aloittaja MacDo, heinäkuu 29, 2006, 08:14:49 AP

« edellinen - seuraava »

MacDo

Hi,

I'm sorry to write a so long history for a little question but I think that you could better understand if I show you all the steps... If you have any complementary suggestion, you're welcome... ;-) Thank you in advance !

I managed using the SSI to include a 'login/welcome+logout' on all pages of my website. Here is what I did :
FIRST : I created a file 'login.php' containing the following code :
<h2>Login</h2>
<?php
if ($context['user']['is_guest'])
{
          echo 
'<p>Some welcome message</p>';
          
ssi_login();
}
else
{
          
ssi_welcome();
          echo 
'<br />';
          
ssi_logout();
}
?>

</div>

SECOND : on each page, I put '<?php include('login.php');?>'.

Well. This is ok.

When I login on my website (using the form provided by ssi_login()), It redirects to the forum welcome page.
This was not what I would like : I would like to be redirected to the page of my web site I was on when I filled the login form. So I modify the 'login.php' replacing the ssi_login() line by

$current_url = 'http://www.mydomainname.tld'.$_SERVER['PHP_SELF'];
ssi_login($current_url);

and the logout line similarly. It works fine. BUT... now, logging in using the login form of the smf forum redirects me to the last page visited in my website ! When using the login form in the forum, I would like to be redirected to the forum page (as I would be if I was not using SSI and the forum standalone). But when logging in using the ssi_login in my webpages, I would like to be redirected to my website (like it works now with the login.php file).

Is there a solution ?

Thank you very much for reading me, and much more for helping me :-)

EDIT. Well. I found another problem. When I enter a wrong password in the form on my website (hence in the ssi_login form), I'm redirected to a forum page displaying the error. Is there a way to show the error message on my website and not be redirected to the forum ?

MacDo

up... Please help... It seems that I should edit the redirectexit function but I can't determine how...

Could you help me, pleaaaaaase ? :-)

MacDo

Please excuse me but I really need help...   :-[  :-[ I'm sure this is easy for you...

Here is my question, short version :

When using the login form in the forum, I would like to be redirected to the forum page (as I would be if I was not using SSI and the forum standalone). But when logging in using the ssi_login in my webpages, I would like to be redirected to my website (like it works now with the login.php file).

How can I do that ?

Thank you very much for your help...

MacDo

Ok ; that seems ok, now.

I modified the index.template.php file and add the following lines in the template_main_above() function : echo '</span>';
$_SESSION['login_url'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$_SESSION['logout_url'] = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

around line #238, between
// Otherwise they're a guest - send them a lovely greating...
else
echo $txt['welcome_guest'];

and
// Now, onto our second set of info, are they logged in again?
if ($context['user']['is_logged'])
{
// Is the forum in maintenance mode?


The first line "echo '</span>';" is for XHTML validation and the others are for my redirection problem.

It seems to be functional but is it correct ? I would like to be sure that this modification will not cause additional problems... :-) What's your opinion ?

Advertisement: