PHP/MySQL question I'm currently making an IT support logging system for the company I worked at during my placement. When a user logs in, I want to show some statistics - including number of logins, and a "you last logged in on: .." feature. Im wondering how to store this data? Will the number of logins be done by say having a login variable which will be initially set to 0, and then somewhere in the login script having an update query that increments this value by one? then simply echoing this variable. And in terms of the date...i was thinking that you would write a timestamp to the users table and then echo this on next login...but i was wondering in that case how to stop it from simply showing the timestamp it just recorded? cheers!
The number of logins.. Could you not just add a field called "logins" then refer to this in a variable.. then when the users logs in simply increment the value by 1? for example.. I = "logins" OnSubmit I = I+1 Or something similar. The timestamp.. Just use a datefield and simply allow it to overwrite the date entry. I've not had much sleep so this may be a little vague but it might work.. It seems too simple though..
To do this you would create a login table. It would usually store the following user id timestamp ipaddress of login attempt Did the user give the right password? If you store all of that it's easy to calculate variables such as last login time, number of logins etc to display on a page. Hope that helps.