SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySql table- Last logged on?

    I would like to add a column in an existing MySQL table to log the last logged-on time of each user. What's the easiest way to accomplish this?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ALTER TABLE tablename ADD columnname definition

    Example

    ALTER TABLE tablename ADD lastlogged DATETIME
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How will the time or date being logged in the database?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That was the answer to the first part of the question, I guess I thought you had the other part figured out and just wanted to know how to add a column.

    You'll need to implement sessions or cookies to track when visitors return to yoursite and then update that field when they log in.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I built a user login by using Phakt's PHP extension for Ultradev. It uses session in the script. How do I incorporate the idea into the existing script?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no idea, never used phakt or Ultradev. But it should be a matter of running a function whenever the user logs in that updates that field in the database.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know how to create a function like that?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well assuming you have a session var with the user id from the user table. I would do something like this after ebing logged in.

    PHP Code:
    $result mysql_query("UPDATE usertable set logged = NOW() WHERE id = '$idfromsession'"); 
    I mean its only a matter of updating the record of the user who just logged in with a new timestamp.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool...it's done! Thanks!
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!


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
  •