954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

User Statistics

I have developed 2 Database using MySQL and PHP.
I have created member table in which there is a type of user.
On basis of type I restricted user to view private pages.
Now I wanted to check status of users. when they login, logout means timing of the users.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

use the php function date, it has many parameters to put, look at www.php.net , its easy

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 

I have knowledge about date function.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

I have also know I have to create table in DB in which I have to update at every login and logout for getting my requirement. but I need innovative and easy idea.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

alright, I didn't understand from your first post, sorry

I guess a good way is making a table for all the login entries, where you put the id of the user and the time of login, I guess this is the easiet way.

same thing for logout, in a seprate table.

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 

I have a member table...
So u means , I have to create Login and Logout Table in DB which stores login and logout time?

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

yes, this is the best, as performance and it's neater

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 

in login and logout table which fields necessary for keeping record?

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

basically only the id of the user and the time of login, that is all you need.

But maybe you want to divide the time to columns, like year,month,day,hour,minute... it's up to you

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 
--
-- Table structure for table `members`
--

CREATE TABLE IF NOT EXISTS `members` (
  `MemId` int(5) NOT NULL AUTO_INCREMENT,
  `UserName` varchar(25) NOT NULL,
  `Password` varchar(20) NOT NULL,
  `Type` varchar(20) NOT NULL,
  PRIMARY KEY (`MemId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;

its a table for members, now login and logout table, I only require MemId?

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

yes.

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 

i am still confused

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

when user sign in how i can record it in log in table

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 
--
-- Table structure for table `login`
--

CREATE TABLE IF NOT EXISTS `login` (
  `MemId` int(5) NOT NULL AUTO_INCREMENT,
  `UserName` varchar(25) NOT NULL,
  `Type` varchar(20) NOT NULL,
  'Time' time  NOT NULL,
  'Date' date NOT NULL,
  PRIMARY KEY (`MemId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;

This is my table structure.
Whenever user sign in I check his/her username from members table and on login success I redirect users to private pages on basis of type. Now how I insert record when user sign in.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

as I said you need to make a new table.. columns: user_id Login_time...

when the user logs in you add a new entry in this table (the entry will consist of his id and the time of login)... as simple as that!

theighost
Junior Poster
103 posts since Jan 2009
Reputation Points: 8
Solved Threads: 15
 

please reply.
Its not very difficult.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

Please share ....

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

Can I provide my code to u all ???

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

Thanks. from login success page.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

I have to pages when user sign in .
1. checklogin.php
2 loginsuccess
checklogin.php checks the username and password in Db and redirect it to loginsuccess.php after authentication. on which page i have to put query?

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: