mrt003003 Posted May 30, 2011 Share Posted May 30, 2011 Hi there i was wondering if its possible to have a count down timer (for say 5 mins) that when it reaches 0 a form is updated.. <?php // set countdown timer for 5 mins $countdown = '300' if ($countdown == '0'){ update the form somehow? }?> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <input name="hiddenField" type="hidden" value="<?php echo $row_query['somedata']; ?>" /> <input type="submit" name="Submit" value="Submit" /> </form> I'm a bit of a noob so any help would be ace. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/ Share on other sites More sharing options...
plznty Posted May 30, 2011 Share Posted May 30, 2011 Like a page refresh? If so use headers. Else explain Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222618 Share on other sites More sharing options...
mrt003003 Posted May 30, 2011 Author Share Posted May 30, 2011 No i was thinking more like, at the end of the countdown timer something would replace the function of the submit button and so no submit button would be needed. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222622 Share on other sites More sharing options...
plznty Posted May 30, 2011 Share Posted May 30, 2011 That would probably require AJAX, PHP is a server-side language. Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222623 Share on other sites More sharing options...
mrt003003 Posted May 30, 2011 Author Share Posted May 30, 2011 Hmm is there no way to do it in php alone? Something like: $countdown = '300' if ($countdown == '0'){ if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE table SET something = '1'"); mysql_select_db($database_swb, $swb); $Result1 = mysql_query($updateSQL, $swb) or die(mysql_error()); }?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222633 Share on other sites More sharing options...
plznty Posted May 31, 2011 Share Posted May 31, 2011 No, PHP is server side. Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222651 Share on other sites More sharing options...
mrt003003 Posted May 31, 2011 Author Share Posted May 31, 2011 Do you know of any tutorials with ajax that can help me please?? THanks Quote Link to comment https://forums.phpfreaks.com/topic/237927-update-form-on-countdown/#findComment-1222971 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.