php help

Discussion in 'PHP' started by kumar84, Jul 4, 2007.

  1. #1
    hai

    I have login page with the help of username and password Iam entering into my login ,
    After entering into my login I want to rename my files
    While entering into my login I have a field named lock in my database which is set to 1
    After I signout it will SET TO 0

    That's what i have done

    Now i need is without renaming my files iam in my login for more than 2 minutes means THE lock in the database need to be set to 0 automatically

    for that i need php code
     
    kumar84, Jul 4, 2007 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    To do so you will need another field in your table, let's call it:
    last_activity DATETIME

    Whenever page is loaded you should run such query:

    UPDATE table_name SET lock = 0 WHERE last_activity > DATE_SUB(now(), 2 MINUTES)

    I didn't tested it if won't work then do a search on DATEDIFF() function.
     
    Greg Carnegie, Jul 5, 2007 IP