Jump to content


Photo

Welcome "username"


  • Please log in to reply
2 replies to this topic

#1 Heba

Heba
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 March 2006 - 06:07 AM

Hi

I have a question .. Lets say the user logs in with the name = Heba and goes to the menu page

How can i welcome the user with his name

like Welcome Heba !

I did this
Welcome <? echo "$name";?>

But it gives me this error

Welcome
Notice: Undefined variable: name in

#2 echoninja

echoninja
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 01 March 2006 - 07:05 AM

If you are using sessions, when you first create it in login_process.php or whatever then put
  $session_username=$_POST["username"];
    session_register("session_username");  

then you can display

<? echo $session_username ?>  
anywhere on the page, if someone is logged in then it will display theirname you can expand on that by doing this
<? 
if(!$session_username) //if there is no session username do the following
{ 
echo "You are not logged in, please either <a href=login.php>login</a> or <a href=register.php>register</a>, its free!"; 
} 
else //if there is a session username do the following
{
echo "Welcome Back $session_username"; 
}
 ?>


#3 Heba

Heba
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 March 2006 - 10:12 AM

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users