Jiraiya Posted April 5, 2009 Share Posted April 5, 2009 i want to add a timer to a script of mine so that after the script has run the user will have to wait 10 even if the user leaves that page so how would i do this? Quote Link to comment Share on other sites More sharing options...
xtopolis Posted April 5, 2009 Share Posted April 5, 2009 Store a timestamp in a database/file. Quote Link to comment Share on other sites More sharing options...
Jiraiya Posted April 5, 2009 Author Share Posted April 5, 2009 i dont understand what you mean Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 Something simple like this I'd use an INT UNSIGNED field in the database. 10 - I presume you mean minutes? One monite is 60 so 10 minutes is 600. Write time()+600 into your table $endtime=time()+600; mysql_query("UPDATE table SET endtime=".$endtime); Then just keep checking if the time has expired. $row=mysql_fetch_assoc(mysql_query("SELECT endtime FROM table")); if ($row['endtime']<time()) { //10 minutes is up } else { //10 minutes not yet passed } Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 btw, if you want to calculate the time remaining for the user: $row=mysql_fetch_assoc(mysql_query("SELECT endtime FROM table")); $remaintime=$endtime-time(); echo 'Remaining: '.date('H:i:s',$remaintime); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.