Heba Posted March 1, 2006 Share Posted March 1, 2006 Hi I have a question .. Lets say the user logs in with the name = Heba and goes to the menu pageHow can i welcome the user with his name like Welcome Heba !I did this [code]Welcome <? echo "$name";?>[/code]But it gives me this errorWelcome [b]Notice: Undefined variable: name in[/b] Quote Link to comment Share on other sites More sharing options...
echoninja Posted March 1, 2006 Share Posted March 1, 2006 If you are using sessions, when you first create it in login_process.php or whatever then put [code] $session_username=$_POST["username"]; session_register("session_username"); [/code]then you can display [code]<? echo $session_username ?> [/code]anywhere on the page, if someone is logged in then it will display theirname you can expand on that by doing this[code]<? 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"; } ?>[/code] Quote Link to comment Share on other sites More sharing options...
Heba Posted March 1, 2006 Author Share Posted March 1, 2006 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.