showing username

Newbie Spellweaver
Joined
Jul 16, 2007
Messages
20
Reaction score
0
Im trying to display a logged in user's username

I have a login script, i have a cookie, and i know that $user is the username used in the cookie. My header is modified so that i can use $user in the file, but it wont work...ill post the code:

PHP:
<div class="leftc">
		<div class="blockTitlel">Member Panel</div>
			<div class="blockContentl">
<?php
echo('Welcome back, '.$user.'.');
?>
<BR><BR>
<a href="newpost.php">Post!</a><BR>
<a href="logout.php">Logout</a><BR>
	</div>
</div>

This file is used as an include to my index.php...when i browse to that page, i see: Welcome back, .

Could you guys help me please?
 
Hmm, you will have to post more of the code. Apparently the variable is empty.
 
O.K. Here's some more code (the cookie is there, i've checked it...twice!
here my code that's in all of my header's:

PHP:
 if ($_SESSION['logged_in'] != 1 && isset($_COOKIE['login_cookie'])) {
    list($user, $pass) = explode('[]', $_COOKIE['login_cookie']);
     $qu = mysql_query("SELECT `user_password` FROM `members` WHERE `username` = '".addslashes($user)."'");
    if (mysql_num_rows($qu) == 1) {
        $passw = mysql_fetch_object($qu);
        if ($passw->user_password == $pass) {
          $_SESSION['logged_in'] = 1;
           $_SESSION['username'] = $user;
            $_SESSION['password'] = $pass;
        }
    }
 }

if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
   $_SESSION['logged_in'] = 0;
   $user = "Guest"; 
 }
?>
 
Are you sure that:

list($user, $pass) = explode('[]', $_COOKIE['login_cookie']);

works?
 
Back