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(); ?> Quote Link to comment 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 ... Quote Link to comment 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']; Quote Link to comment 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 Quote Link to comment 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() Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted September 21, 2007 Share Posted September 21, 2007 On forums, this is called 'flood control' Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.