Forum Moderators: coopster

Message Too Old, No Replies

Question about showing username....

         

xkid

4:25 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



Hi.

I want to show something like "logged in as: testuser" on my page..
How can i get that information from my mysql table?

thanks

gettopreacherman

7:31 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



If you are using cookies, which you should be if you are maintaining a logged in session, you should be able to pull that information from the cookie

mcibor

9:10 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it'll be sth like this:

On validation page:

<?php
session_start();
if (validate() === true) $_SESSION["user"] = $valid_user;
?>

On other pages:

<?php
session_start();
if(!isset($_SESSION["user"]){
header("Location: index.html");
die();} //redirect to login page

echo "logged in as: ".$_SESSION["user"];
?>


Hope this helps you start
Michal Cibor

And welcome to WebmasterWorld!

xkid

12:28 pm on Jul 23, 2005 (gmt 0)

10+ Year Member



thanks! :)

that did the trick! :D