Jump to content

If there is information in one filed then update another..


oskare100

Recommended Posts

Hello,
I have a few fileds in my database where I want to save information about which IP addresses my members have when they login.

In one table I've fields for the username, password, member group and so on. Then I've a few fields with the names login_ip_1, login_ip_2, login_ip_3, login_ip_4 and login_ip_5 where I want to save the IP numbers the member used when he/she loged in the four last times.

So basicly what I need to do it that if let say a user log in with one IP the ip is saved in the login_ip_1 field. If then the user logs in again with another IP I want that one to be saved in login_ip_2 and so on until login_ip_5 and when login_ip_5 is filled I want it to send an email.. but that last part with the reporting shouldn't be a problem.

Best Regards
Oskar R
well first off that will give you a max of 5 recorded ip's.  Instead use 2 tables, one will be for storing user data (username, password, etc) and their user id.  Then in the second table, record ip's with it.  (table will look like id, ip, userid).  Now each time an ip is stored, store their userid with it so it can be matched to a username from table 1.  Hope it makes sense.

Table 1:
id
username
password
email
etc etc

Table 2:
id  (not user id, this is the ip's id)
ip_address
user_id  (the user id corresponding to this ip address)

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.