Jump to content

Logging User Information Each Time They Log In


dzhax

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.

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

Your funny :) What data type would the ip have to be to hold an array in a single field?How would I query all of the results from that single field?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...