Topic: Logged in/Logged out Info box

Has anyone create something like this?

http://img106.imageshack.us/img106/4479/punbbuser5aa.gif
Basically it just shows your avatar, name, other info about you if you are logged in and if not shows the Welcome guest and register link. Perhaps a login box would be better though?

Re: Logged in/Logged out Info box

Like... a page that's shown after you log in?
Should be quite easy to do... *wanders off to make it*

Re: Logged in/Logged out Info box

I found a thread that kinda had what I wanted
http://punbb.org/forums/viewtopic.php?id=8786

So I modified that along with some other code others helped me with on the random profile and here's what I got, which is what I wanted smile


<?php
$punbb_path = $_SERVER['SCRIPT_FILENAME'];
$punbb_path = './punbb/';

define('PUN_ROOT', "$punbb_path");
require PUN_ROOT.'include/common.php';

define('PUN_TURN_OFF_MAINT', 1); // if forums go down the site will not
define('PUN_QUIET_VISIT', 0); // update last visit when outside of the forums
?>

<?
if($pun_user['id'] > 1)
{ 
$query = "SELECT id, username, last_visit FROM ".$db->prefix."users WHERE id='".$pun_user['id']."'";
$result = $db->query($query) or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());

$data = $db->fetch_assoc($result);

if ($pun_user['show_avatars'] != '0')
        {
        $avatars_dir="punbb/img/avatars/";//avatars are located here
        
            if ($img_size = @getimagesize($avatars_dir.'/'.$data['id'].'.gif'))
                $user_avatar = '<img src="'.$avatars_dir.'/'.$data['id'].'.gif" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($avatars_dir.'/'.$data['id'].'.jpg'))
                $user_avatar = '<img src="'.$avatars_dir.'/'.$data['id'].'.jpg" '.$img_size[3].' alt="" />';
            else if ($img_size = @getimagesize($avatars_dir.'/'.$data['id'].'.png'))
                $user_avatar = '<img src="'.$avatars_dir.'/'.$data['id'].'.png" '.$img_size[3].' alt="" />';
        }
        else
            $user_avatar = '';

echo $user_avatar . "<br />";
echo 'Welcome to ----, <strong>'. $data['username'] . '</strong>.<br />';
echo "Last visit: " . date('M j, Y h:i:s a' , $data['last_visit']) . "<br />";
}
else
{// show login forum
    echo "Welcome to ----, Guest.";
?>


<!--update urls-->
<form id="login" method="post" action="/punbb/login.php?action=in" onsubmit="return process_form(this)">
<input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="redirect_url" value="<?php echo $_SERVER['SCRIPT_NAME'] ?>" /><!-- remove that if you dont want redirect to this same page, it will go to forum index instead-->
<label class="conl"><strong>Username</strong><br /><input type="text" name="req_username" size="25" maxlength="25" tabindex="1" /><br /></label>
<label class="conl"><strong>Password</strong><br /><input type="password" name="req_password" size="16" maxlength="16" tabindex="2" /><br /></label>
<p class="clearb">If you have not registered or have forgotten your password click on the appropriate link below.</p>
<p><a href="/punbb/register.php" tabindex="4">Not registered yet?</a>  
<a href="/punbb/login.php?action=forget" tabindex="5">Forgotten your password?</a></p>
<p><input type="submit" name="login" value="Login" tabindex="3" /></p>
</form>
<?php
}
?>