SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of using a bunch of fields, how about create a different table just for this?

    table login_ips
    userid | ip | login_time

    each time they log in
    select ip from login_ips where userid = $userid

    count the number of results.
    see if thier current ip exists in the results.
    if not, insert a new record.

    if this insert will cause them to have more than 4 records, email.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •