sayedsohail Posted September 21, 2007 Share Posted September 21, 2007 Hi, Can someone explain this code for me please? <?php define('POST_DELAY', 30); if(time() - $_SESSION['last_access'] > POST_DELAY) { // run update queries } else { echo "You must wait " . POST_DELAY . " seconds before submitting another post."; } $_SESSION['last_access'] = time(); ?> Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/ Share on other sites More sharing options...
thryb Posted September 21, 2007 Share Posted September 21, 2007 set your posting delay at 30 sec, if the time is > than 30 sec (last post) then you can execute the query you want if not then you must wait ... Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352369 Share on other sites More sharing options...
sayedsohail Posted September 21, 2007 Author Share Posted September 21, 2007 what does the define do and what about $_SESSION['last_access']; Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352377 Share on other sites More sharing options...
hvle Posted September 21, 2007 Share Posted September 21, 2007 define assigned a value to a constant, in this code, it will assign 30 to constant POST_DELAY $_SESSION['last_access'] hold the time in which user last updated the query or attempted to update query Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352390 Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 You could have looked some of this up in the manual, like define() Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352404 Share on other sites More sharing options...
LemonInflux Posted September 21, 2007 Share Posted September 21, 2007 On forums, this is called 'flood control' Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352427 Share on other sites More sharing options...
sayedsohail Posted September 21, 2007 Author Share Posted September 21, 2007 define assigned a value to a constant, in this code, it will assign 30 to constant POST_DELAY $_SESSION['last_access'] hold the time in which user last updated the query or attempted to update query How do i assign the value to $_SESSION['last_access']; i am not sure if the last_access is the reserved value variable for sessions, or i need to assing the value to this variable. Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352448 Share on other sites More sharing options...
HuggieBear Posted September 21, 2007 Share Posted September 21, 2007 You can assign a value to it like this: $_SESSION['last_access'] = now(); Regards Huggie Link to comment https://forums.phpfreaks.com/topic/70163-solved-can-someone-explain-this-code-please/#findComment-352451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.