freddyw Posted September 5, 2009 Share Posted September 5, 2009 Hi there. Is there a way to recognise the user that is logged on, on other pages of my site. For example I want it to say Hello (first_name). Rather than username. form the first name they enetered when signing up. id connect to the db (obviously, but after that im stumped. Link to comment https://forums.phpfreaks.com/topic/173272-recognise-a-logged-on-user/ Share on other sites More sharing options...
bundyxc Posted September 5, 2009 Share Posted September 5, 2009 Try something similar to this: $sql = "SELECT `firstName` FROM `users` WHERE `username`=" . $username; $query = mysql_query($sql); $fetch = mysql_fetch_assoc($query); print($fetch['firstName']); Link to comment https://forums.phpfreaks.com/topic/173272-recognise-a-logged-on-user/#findComment-913367 Share on other sites More sharing options...
kratsg Posted September 5, 2009 Share Posted September 5, 2009 Try something similar to this: $sql = "SELECT `firstName` FROM `users` WHERE `username`=" . $username; $query = mysql_query($sql); $fetch = mysql_fetch_assoc($query); print($fetch['firstName']); I think he needs a way to get users to log on first. In that case, I suggest you check out this tutorial:http://fishbowl.pastiche.org/2004/01/19/persistent_login_cookie_best_practice/ Link to comment https://forums.phpfreaks.com/topic/173272-recognise-a-logged-on-user/#findComment-913370 Share on other sites More sharing options...
freddyw Posted September 6, 2009 Author Share Posted September 6, 2009 no i already have users to log on Link to comment https://forums.phpfreaks.com/topic/173272-recognise-a-logged-on-user/#findComment-913389 Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 no i already have users to log on Use whatever method in your cookies/sessions that they log on with to fetch their information from the database: Try something similar to this: $sql = "SELECT `firstName` FROM `users` WHERE `username`=" . $username; $query = mysql_query($sql); $fetch = mysql_fetch_assoc($query); print($fetch['firstName']); Link to comment https://forums.phpfreaks.com/topic/173272-recognise-a-logged-on-user/#findComment-913391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.