Jump to content

Archived

This topic is now archived and is closed to further replies.

Heba

Welcome "username"

Recommended Posts

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 [code]Welcome <? echo "$name";?>[/code]

But it gives me this error

Welcome
[b]Notice: Undefined variable: name in[/b]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.