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? Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/ Share on other sites More sharing options...
mikefrederick Posted August 6, 2008 Share Posted August 6, 2008 use a cron job Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/#findComment-609895 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 Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/#findComment-609899 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; Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/#findComment-609903 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 } ?> Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/#findComment-609905 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. Link to comment https://forums.phpfreaks.com/topic/118475-how-to-wait-for-only-6-hrs-to-reply-for-the-challenge/#findComment-609912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.