Jump to content

Welcome "username"


Heba

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.