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
https://forums.phpfreaks.com/topic/93118-echo-username-whilst-logged-in/
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

Archived

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

×
×
  • 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.