Go Back   Dedicated Server Hosting | VPS Hosting | Virtual Private Servers Forum > Support > PHP Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-08-09, 07:22
BOD Member
 
Join Date: May 2009
Posts: 50
Default Caputre Time in/out

Is there a way to capture the login/out time for each member on my site? They have to login to use most functions. They don't have to log out.
Reply With Quote
  #2 (permalink)  
Old 06-08-09, 09:24
BOD Member
 
Join Date: May 2009
Posts: 49
Default

You can put in two date/time fields and this should store the user's login/out info.
Reply With Quote
  #3 (permalink)  
Old 06-08-09, 11:19
BOD Member
 
Join Date: Jun 2009
Posts: 50
Default

I take it you want to do something like capture the amount of time a user has stayed logged in? Well, first, like alyaly said, you'll need to make sure your database has the required tables to handle the login/logout date and time info. Then you'll to use PHP to capture the login time and enter it into the database. Something a little like this:

PHP Code:
$login_date date("Y-m-d h:i:s"); 
$sql "UPDATE ".$tbl_name." SET lastLogin='".$login_date()"' WHERE userid=username";
$result mysql_query($sql) or die(mysql_error()); 
You'll have to make changes where necessary, of course, but you get the idea.
Reply With Quote
  #4 (permalink)  
Old 06-09-09, 06:44
BOD Member
 
Join Date: May 2009
Posts: 50
Default

Quote:
Originally Posted by surreality View Post
I take it you want to do something like capture the amount of time a user has stayed logged in? Well, first, like alyaly said, you'll need to make sure your database has the required tables to handle the login/logout date and time info. Then you'll to use PHP to capture the login time and enter it into the database. Something a little like this:

PHP Code:
$login_date date("Y-m-d h:i:s"); 
$sql "UPDATE ".$tbl_name." SET lastLogin='".$login_date()"' WHERE userid=username";
$result mysql_query($sql) or die(mysql_error()); 
You'll have to make changes where necessary, of course, but you get the idea.
Exactly what I've been looking for myself. Thanks a lot for posting the code. I'm going to give this a try and see how well it works for me.
Reply With Quote
  #5 (permalink)  
Old 06-09-09, 06:53
BOD Member
 
Join Date: May 2009
Posts: 50
Default

Quote:
Originally Posted by surreality View Post
I take it you want to do something like capture the amount of time a user has stayed logged in? Well, first, like alyaly said, you'll need to make sure your database has the required tables to handle the login/logout date and time info. Then you'll to use PHP to capture the login time and enter it into the database. Something a little like this:

PHP Code:
$login_date date("Y-m-d h:i:s"); 
$sql "UPDATE ".$tbl_name." SET lastLogin='".$login_date()"' WHERE userid=username";
$result mysql_query($sql) or die(mysql_error()); 
You'll have to make changes where necessary, of course, but you get the idea.
Got'cha Surreality. I was thinking along these lines but was still too unsure to give it a try on my own.Thanks for the help.
Reply With Quote
  #6 (permalink)  
Old 06-09-09, 23:13
BOD Member
 
Join Date: Jun 2009
Posts: 57
Default

Personally, I prefer just using a pre-made script or CMS to do things like this for me. I'm no PHP expert, so I can't really change the code much without messing things up. >_<
Reply With Quote
  #7 (permalink)  
Old 06-10-09, 14:01
Shane Phillips's Avatar
Chief Operating Officer
 
Join Date: Dec 2006
Posts: 1,057
Send a message via AIM to Shane Phillips Send a message via MSN to Shane Phillips
Default

Quote:
Originally Posted by Jenny Walker View Post
Personally, I prefer just using a pre-made script or CMS to do things like this for me. I'm no PHP expert, so I can't really change the code much without messing things up. >_<
CMS should work for you.

Regards,

Shane Phillips
__________________
Redundant Dedicated Server Hosting Solutions Only at BODHost
24x7 Toll-Free ph. : +1. 866-662-0909
Email : sales@bodhost.com | MSN : sales@bodhost.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 11:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2008, BODHost.com. All rights reserved.