View Full Version : Personalized Welcome Message

Kristy S
05-23-2012, 02:04 PM
Hi all, this is my very first post here. I am having a small issue and I believe it has something to do with my where clause in MySQL that I am missing.
I am using Dreamweaver CS5 and MySQL database. I have created a log in page and my database is updating with the usernames and passwords. So that's all good. Now once they are logged into the members.php page I would like to have a Welcome logged in username, message at the top of the page. Sort of like the one at the top of this page only saying of course Welcome.

I have created a recordset like this:
SELECT username
FROM users

When I click the test button I do see all the user names in my database table called users. So it does work however it's only pulling the very first username (that I entered into the database) no matter who's logged in. Which is not cool if Billy Bob or Susie Q is logged in and he/she sees a Welcome Kristy, message!

I did a simple google search and there was a post about needing to put a where clause of MM_users which I did try but got an error message in sql about unknown column in MM_users in where clause. Could someone help point me to the right where clause if I do infact need one. Or what I need to change to my record set to have the welcome logged in username displayed at the top of the page. Thank you so much.
Kristy S.

05-23-2012, 04:14 PM
Assuming you have created a session once the user is logged in and that carries a user's ID around the website with it then you should create a where clause using that. So select username from users where id = session_id.

That is the theory and not the code by the way!

05-24-2012, 12:59 AM
or on page Welcome <?php echo $row['username'] ;?> maybe, editing $row to the var you use for your recordset or session value as corrosive suggests if on a new page