Jump to content

Logging User Information Each Time They Log In


dzhax
 Share

Recommended Posts

For security purposes we have decided that we want to log each users information each time they log in to our website. More specifically the ip address they log in from. This way if we need to ip ban a user, we can query all of the ips the user ever logged in on and ban those ips. Of course we will have a list of safe ips that will not be banned regardless.Is there a way to make a table for this in phpmyadmin (mysql)?Would need something that will hold the following information:UsernameIpTimestamp (M,D,Y ##:##)But If possible have a record for each user and a dropdown menu (like the lookup wizard) with the ips in it.Also if this is possible how would I INSERT it in and how could i SELECT it for a certain user showing all ips? (I can convert it to be used into php later)Thanks a bunch.

Edited by dzhax
Link to comment
Share on other sites

Is there a way to make a table for this in phpmyadmin (mysql)?
Yes.
Would need something that will hold the following information:UsernameIpTimestamp (M,D,Y ##:##)
Looks fine to me.
Also if this is possible how would I INSERT it in
With an INSERT query.
how could i SELECT it for a certain user showing all ips?
With a SELECT DISTINCT query.
Link to comment
Share on other sites

Databases don't support arrays. If you want to query several elements, you need to put them in several rows in another table, which is sort of like an array itself. You can also serialize an array in PHP to turn it into a string and save it in a field that accepts text, and then use PHP to unserialize the string to turn it back into an array.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...