-Karl- Posted May 22, 2010 Share Posted May 22, 2010 I have a button, which carries out a function which is server intensive. How would I utilize the timestamp function to make it so that someone can only use this button, lets say. Once every 2 hours? Quote Link to comment https://forums.phpfreaks.com/topic/202574-limit-clicks-with-timestamps/ Share on other sites More sharing options...
teamatomic Posted May 22, 2010 Share Posted May 22, 2010 When a person clicks the button write the timestamp to a db field. Then you have two choices. when a user accesses the page with the button you can check the stored timestamp against the current timestamp and not show the button or you can wait until the button is click and look for the users stored timestamp and match it and do nothing. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/202574-limit-clicks-with-timestamps/#findComment-1061926 Share on other sites More sharing options...
-Karl- Posted May 22, 2010 Author Share Posted May 22, 2010 Aye, but how wold I check the timestamp. Quote Link to comment https://forums.phpfreaks.com/topic/202574-limit-clicks-with-timestamps/#findComment-1061927 Share on other sites More sharing options...
jcbones Posted May 22, 2010 Share Posted May 22, 2010 <?php session_start(); if($_GET['userclickedbutton'] == 1) { $check = $_SESSION['timestamp']; $now = time(); if($now - $check >= 7200) { $_SESSION['timestamp'] = time(); //allow function } else { //deny function write error } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/202574-limit-clicks-with-timestamps/#findComment-1061954 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.