Spring Posted December 6, 2010 Share Posted December 6, 2010 Is there a way to use PHP time to only allow a user to press a button in a form (for example a submit button) once a day? If so, could I get an example? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/ Share on other sites More sharing options...
devilinc Posted December 6, 2010 Share Posted December 6, 2010 what i would suggest you is to use difference of 2 times,with the second time being 24 hours ahead of the first and then doing a condition check to allow the submit button to be enabled only after the time lapse of 24 hrs Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143638 Share on other sites More sharing options...
ManiacDan Posted December 6, 2010 Share Posted December 6, 2010 Record the click time of the button somewhere (sessions or database). Every time they click, check to see if there's a previous click from them less than 24 hours ago. The session will expire when they close their browser, and the database must be linked to their account somehow (unless this button is global and can only be clicked by anyone once a day. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143647 Share on other sites More sharing options...
Spring Posted December 6, 2010 Author Share Posted December 6, 2010 I'm not sure how that would, that's why I wanted an example, how do I use the php time function to check if they clicked within 24 hours? Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143724 Share on other sites More sharing options...
AbraCadaver Posted December 6, 2010 Share Posted December 6, 2010 Depends on what you mean by "once a day". If I click today (Monday) at 11:59PM, can I click again tomorrow (Tuesday) at 12:01AM even though it's been only 2 minutes? Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143737 Share on other sites More sharing options...
Spring Posted December 7, 2010 Author Share Posted December 7, 2010 Depends on what you mean by "once a day". If I click today (Monday) at 11:59PM, can I click again tomorrow (Tuesday) at 12:01AM even though it's been only 2 minutes? Just 24 hours time. All I want is a 24 hours between clicks on the submit button for each person. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143812 Share on other sites More sharing options...
Spring Posted December 7, 2010 Author Share Posted December 7, 2010 Still looking for a simpler soultion, this should be possible without having to use the database, how would I check it with sessions? anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143840 Share on other sites More sharing options...
Spring Posted December 7, 2010 Author Share Posted December 7, 2010 I fixed by using sessions like suggested, thanks for everyones support. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143861 Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2010 Share Posted December 7, 2010 I don't see how that's possible. As was mentioned above, sessions expire when the user closes their browser. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143863 Share on other sites More sharing options...
Spring Posted December 7, 2010 Author Share Posted December 7, 2010 I don't see how that's possible. As was mentioned above, sessions expire when the user closes their browser. session_set_cookie_params() worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143866 Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2010 Share Posted December 7, 2010 The user can simply delete the session cookie. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143868 Share on other sites More sharing options...
Spring Posted December 7, 2010 Author Share Posted December 7, 2010 The user can simply delete the session cookie. Yeah i know. I'll inevitable have to use the database to store the timestamp, but this is a temporary fix until tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/220831-php-time-help/#findComment-1143869 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.