...

View Full Version : loggen-in status



finoy_ako
02-18-2010, 12:55 PM
anyone here can share the code for logged-in status??

heres the my code



<form action="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login" method="post">
<h3><a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login">Login</a> <a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=register">Register</a></h3>
<fieldset>
<label for="username">Username:</label>
<input type="text" name="username" id="username" size="10" title="Username" />
<label for="password">Password:</label>
<input type="password" name="password" id="password" size="10" title="Password" />
<label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" /></label>
<input type="submit" name="login" value="Login" />
</fieldset>
<input type="hidden" name="redirect" value="http://romelad.freehostia.com" />
</form>



I redirect the user logged-in at http://romelad.freehostia.com not at he forum board and when I logged in the logged-in or online status didn't show.


can you please share your additional code to show the online status when I log-in.

mlseim
02-18-2010, 04:19 PM
phpbb3 uses PHP sessions to keep track of the users that are logged-in.
Outside of phpbb3, you can still use their sessions to check if the user is logged-in.

So, without testing anything ... I'm thinking you might put the code below at the
top of any pages you wish to check ... outsite of phpbb3:



<?php
session_start();
define('IN_PHPBB', true);
$phpbb_root_path = './phpbb3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if($user->data['is_registered']){
echo('<span style="font-size:13pt; font-weight:bold; color:#d31044;">Welcome Back '.$user->data['username'].'! </span> &nbsp; | &nbsp; <a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id). '" class="textlink">Log out</a>');
echo"<br />";

// include whatever pages or files you want ... where the user is logged-in.

}
else{

// the user is not logged-in, so give them a login page, or kick them out.

}
?>

finoy_ako
02-19-2010, 05:25 AM
thanks sir, you helped me a lot, but the thing is the input box for log-in and password is still there even they show me the words welcome back.

please try to register and log-in to see the problem.
link
http://romelad.freehostia.com

mlseim
02-19-2010, 01:16 PM
You'll have to show us the script (file) for that page, so we can see why
the login-box still shows. There must be an "if" statement missing or misplaced.

auriaks
02-19-2010, 01:24 PM
You could use this:

<form action="ucp.php?mode=login" method="post">
instead of this:

<form action="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login" method="post">
if php script is in the same page as form.

Also, can you tell me about the online thing? When the program will tell if user is online? I see that you send just a word "online", but there must be more difficult code in the online system. I can say some examples later if you want.

finoy_ako
02-19-2010, 01:42 PM
heres my code



<?php
session_start();
define('IN_PHPBB', true);
$phpbb_root_path = './phpbb3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if($user->data['is_registered']){
echo('<span style="font-size:13pt; font-weight:bold; color:#d31044;">Welcome Back '.$user->data['username'].'! </span> &nbsp; | &nbsp; <a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id). '" class="textlink">Log out</a>');
echo"<br />";

// include whatever pages or files you want ... where the user is logged-in.

}
else{

// the user is not logged-in, so give them a login page, or kick them out.

}
?>



<form action="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login" method="post">
<h3><a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login">Login</a> • <a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=register">Register</a></h3>
<fieldset>
<label for="username">Username:</label>
<input type="text" name="username" id="username" size="10" title="Username" />
<label for="password">Password:</label>
<input type="password" name="password" id="password" size="10" title="Password" />
<label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" /></label>
<input type="submit" name="login" value="Login" />
</fieldset>
<input type="hidden" name="redirect" value="http://romelad.freehostia.com" />
</form>








You'll have to show us the script (file) for that page, so we can see why
the login-box still shows. There must be an "if" statement missing or misplaced.

Sir mlseim the script I use is in my first post and I added your script too.


sir auriaks I just followed the tutorial link below and they say I need to change phpBB3 to whatever folder my forum is in.

http://wiki.phpbb.com/Practical.External_login

mlseim
02-19-2010, 04:17 PM
Try this:



<?php
session_start();
define('IN_PHPBB', true);
$phpbb_root_path = './phpbb3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if($user->data['is_registered']){
echo('<span style="font-size:13pt; font-weight:bold; color:#d31044;">Welcome Back '.$user->data['username'].'! </span> &nbsp; | &nbsp; <a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id). '" class="textlink">Log out</a>');
echo"<br />";

// user is logged-in

}
else{

// user is NOT logged-in, so display the login form ...
?>

<form action="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login" method="post">
<h3><a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=login">Login</a> • <a href="http://romelad.freehostia.com/phpbb3/ucp.php?mode=register">Register</a></h3>
<fieldset>
<label for="username">Username:</label>
<input type="text" name="username" id="username" size="10" title="Username" />
<label for="password">Password:</label>
<input type="password" name="password" id="password" size="10" title="Password" />
<label for="autologin">Log me on automatically each visit <input type="checkbox" name="autologin" id="autologin" /></label>
<input type="submit" name="login" value="Login" />
</fieldset>
<input type="hidden" name="redirect" value="http://romelad.freehostia.com" />
</form>

<?php
}
?>

finoy_ako
02-20-2010, 04:35 AM
thanks sir its now working, I just forgot to combine the code. hehe.

thanks again sir.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum