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? Link to comment https://forums.phpfreaks.com/topic/152616-how-would-i-do-this-in-php/ Share on other sites More sharing options...
xtopolis Posted April 5, 2009 Share Posted April 5, 2009 Store a timestamp in a database/file. Link to comment https://forums.phpfreaks.com/topic/152616-how-would-i-do-this-in-php/#findComment-801538 Share on other sites More sharing options...
Jiraiya Posted April 5, 2009 Author Share Posted April 5, 2009 i dont understand what you mean Link to comment https://forums.phpfreaks.com/topic/152616-how-would-i-do-this-in-php/#findComment-801646 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 } Link to comment https://forums.phpfreaks.com/topic/152616-how-would-i-do-this-in-php/#findComment-801650 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); Link to comment https://forums.phpfreaks.com/topic/152616-how-would-i-do-this-in-php/#findComment-801652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.