Jump to content

echo username whilst logged in?


burge124

Recommended Posts

hi,

ive got a standard login page named checklogin.php with user id called UserName. id like to echo on all of the pages that they visit whilst logged in their username (similar to this pages top left hand corner "Hello "UserName"".

 

Do i need to use this function or is this just to check that the user is registered?

 

<?

session_start();

if(!session_is_registered(myusername)){

header("location:main_login.php");

}

?>

 

do i need to use an include function from the checklogin.php page?

thanks

Link to comment
Share on other sites

in your login code

 

add

 

$_SESSION["UserName"] = "the username info, mysql you need to run a query then dispaly the result eg" $RS["userName"]

 

then on everypage have your

 

session_start();

 

then to call the session either put it in a variable and write the variable or straight up use the session eg

 

echo $_SESSION["UserName"]

 

or in a variable

 

$user = $_SESSION["UserName"]

 

echo $user

 

simple

 

that code you are quotign above is to check it the user is regsitered yes

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.