TheFreak Posted August 6, 2008 Share Posted August 6, 2008 I am making a script which waits for only 6 hours for the user to accept the challenge and if he doesn't he loses the challenge.How can i do that any guesses? Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted August 6, 2008 Share Posted August 6, 2008 use a cron job Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted August 6, 2008 Share Posted August 6, 2008 Save the start time in the database, then check the submitted response time against the start time... if it is longer than six hours, give them the wha wha whaaaaaa(Prices Right sound effects) and deny them. If not, challenge complete Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 6, 2008 Share Posted August 6, 2008 Save the start time in the database, then check the submitted response time against the start time... if it is longer than six hours, give them the wha wha whaaaaaa(Prices Right sound effects) and deny them. If not, challenge complete In addition, you can combine this with mikefrederick's suggestion and auto-fail them at 6 hours by running a cron job every minute (or five, or ten) that checks for expired challenges. The nice thing is that it can all be done with one query: SELECT * FROM challenges WHERE submission_time < CURTIME() - INTERVAL 6 HOUR; That returns all expired (older than 6 hours) challenges. You could even have an expired column where you can update them all in one query, too: UPDATE challenges SET expired = 1 WHERE submission_time < CURTIME() - INTERVAL 6 HOUR; Quote Link to comment Share on other sites More sharing options...
Jabop Posted August 6, 2008 Share Posted August 6, 2008 <?php if ($now < $time_sent+$time_limit) { // do stuff } ?> Quote Link to comment Share on other sites More sharing options...
TheFreak Posted August 6, 2008 Author Share Posted August 6, 2008 use a cron job i don't know about it. Quote from: MatthewJ on Today at 12:13:29 PM Save the start time in the database, then check the submitted response time against the start time... if it is longer than six hours, give them the wha wha whaaaaaa(Prices Right sound effects) and deny them. If not, challenge complete Smiley In addition, you can combine this with mikefrederick's suggestion and auto-fail them at 6 hours by running a cron job every minute (or five, or ten) that checks for expired challenges. I was more into showing the user how much time is left,don't want to use ajax but a simple php time clock types. 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.