tauchai83 Posted February 13, 2007 Share Posted February 13, 2007 Well, I have a login page that would like to track the last login page of the user. When their login is succeed, I will update the table and set it to NOW() which work well and save into DB. My problem is I would like to display the last login datetime to the user. ie, Your last login was. $date But since I update each time user login, they will get the same date as they are logging now. Should i add another column? Please guide me. Thank you! Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/ Share on other sites More sharing options...
tcollie Posted February 13, 2007 Share Posted February 13, 2007 Just add another field to your db called last_login and when they login, take the current login time field and set it as the last login time and then set the current login time field. Does that make sense? Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/#findComment-183501 Share on other sites More sharing options...
trecool999 Posted February 13, 2007 Share Posted February 13, 2007 The easiest and simplest way I could think of is to have a clockin a text box, turn the value into a variable and send it . But that's just me . Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/#findComment-183504 Share on other sites More sharing options...
tauchai83 Posted February 13, 2007 Author Share Posted February 13, 2007 if( strcmp( $ValidPassword[1], $txtPassword) == 0 ) { $complete = 1; $userid = $txtUserID; session_register('userid'); $HTTP_SESSION_VARS['userid'] = $userid; $sql="UPDATE customer SET Last_active=NOW() WHERE Cust_id='$userid'"; $result=mysql_query($sql); ............ ............ I want the user see their own last login date. If Admin see, it's easy because I can just retrive from DB. But for user themselve, once they login, the date already updated, so when i retrive, I'll get the updated date. I have a Last_active coloumn in my DB. I wonder if there is a need to add one more colomn called Current_active_date.Any idea? Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/#findComment-183508 Share on other sites More sharing options...
tcollie Posted February 13, 2007 Share Posted February 13, 2007 Okay so why don't you just set a session variable called 'last_login' with the login time/date from the database when you validate their password BEFORE updating your record to reflect the current login time. if( strcmp( $ValidPassword[1], $txtPassword) == 0 ) { $complete = 1; $userid = $txtUserID; //Get Last Login Time From DB Here //Set Session Variable 'last_login' here //Then Continue On With Database Update To Reflect Current Login Time session_register('userid'); $HTTP_SESSION_VARS['userid'] = $userid; $sql="UPDATE customer SET Last_active=NOW() WHERE Cust_id='$userid'"; $result=mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/#findComment-183517 Share on other sites More sharing options...
tauchai83 Posted February 13, 2007 Author Share Posted February 13, 2007 problem solved. Thank you so much! it was a simple but effective idea. Thanks. Link to comment https://forums.phpfreaks.com/topic/38290-solved-last-active/#findComment-183522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.