Automated PHP Based on timing ?

Discussion in 'PHP' started by xkaser101, Jul 19, 2011.

  1. #1
    Hello the title is not clear at all I know but here is what I am trying to accomplish :
    When A User clicks a button I want the page to lock for 24 Hour period nothing fancy just that It will replace the content with an echo message saying to come back in 24 hours and I want it to stay locked for him even after he quits the page, I thought I can accomplish this using sessions but, they could just delete the session cookie and remove the lock timer, right ? ( I might be wrong and that's where I need an expert's opinion )
    And then I thought I can do this with Mysql but I can't figure out a way to make it work.
    Please help, If this is possible in any other method tell me.

    Thanks in advance,
    Kind Regards,
    Issa Shamoun
     
    Solved! View solution.
    Last edited: Jul 19, 2011
    xkaser101, Jul 19, 2011 IP
  2. #2
    Its pretty easy.
    
    <?php
    if(isset($_POST['buttonName']))
    {
    mysql_query("INSERT INTO lockdowns (ip, time) VALUES ('{$_SERVER['REMOTE_ADDR']}', '{time()}')");
    }
    
    $count = mysql_num_rows(mysql_query("SELECT * FROM lockdowns WHERE ip = '{$_SERVER['REMOTE_ADDR']}' AND time > '{time() - 3600}')");
    if($count > 0) { die("LOCKDOWN"); }
    
    else
    {
    
    // Content of the site when its not locked 
    
    }
    ?>
    PHP:
     
    CrostE, Jul 19, 2011 IP
  3. xkaser101

    xkaser101 Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks alot mate !!!!!!! i got it to work !

    Best Regards !
     
    xkaser101, Jul 19, 2011 IP