oskare100 Posted November 23, 2006 Share Posted November 23, 2006 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 RegardsOskar R Link to comment https://forums.phpfreaks.com/topic/28273-if-there-is-information-in-one-filed-then-update-another/ Share on other sites More sharing options...
ataria Posted November 23, 2006 Share Posted November 23, 2006 just do if statements..if (!$login_ip_1) { // Log IP.}elseif (!$login_ip_2) {// LOG IP.}elseif (!$login_ip_2) {// LOG IP.}elseif (!$login_ip_4) {// LOG IP.}else {// LOG IP.} Link to comment https://forums.phpfreaks.com/topic/28273-if-there-is-information-in-one-filed-then-update-another/#findComment-129289 Share on other sites More sharing options...
Stooney Posted November 23, 2006 Share Posted November 23, 2006 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:idusernamepasswordemailetc etcTable 2:id (not user id, this is the ip's id)ip_addressuser_id (the user id corresponding to this ip address) Link to comment https://forums.phpfreaks.com/topic/28273-if-there-is-information-in-one-filed-then-update-another/#findComment-129291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.