Longbin Posted June 11, 2007 Share Posted June 11, 2007 I am writing one guestbook script , create_entry.php is the file to insert data to MYSQL from form ! I would like to know the scripts: "wait X seconds to insert data to MYSQL" to anti-flooding ? Can you help me please Quote Link to comment https://forums.phpfreaks.com/topic/55072-wait-x-seconds-to-insert-data-to-mysql/ Share on other sites More sharing options...
chocopi Posted June 11, 2007 Share Posted June 11, 2007 Use sleep() or usleep() <?php $var = 10; // or whatever you want it to be sleep($var); // 10 seconds usleep($var); // 10 micro seconds ?> Hope it helps, ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55072-wait-x-seconds-to-insert-data-to-mysql/#findComment-272241 Share on other sites More sharing options...
Longbin Posted June 11, 2007 Author Share Posted June 11, 2007 No i mean times between two post like Vbulletin or other BBS System Quote Link to comment https://forums.phpfreaks.com/topic/55072-wait-x-seconds-to-insert-data-to-mysql/#findComment-272249 Share on other sites More sharing options...
chrisuk Posted June 11, 2007 Share Posted June 11, 2007 No i mean times between two post like Vbulletin or other BBS System that's a little different to what your initial post implied I should imagine you would do this using a date calculation, eg current post time and last post time...here is some sample date difference code which you may be able to adapt and then include an if statement, for example, to ensure last post was not less than 10 seconds ago. <?php //time difference $today = strtotime("now"); $logged_day = strtotime("$system_date"); //this is the date the call was logged $timediff_sec = $today - $logged_day; //time difference in seconds $timediff = $timediff_sec/86400; //86400 seconds in a day therefore dividing by this give no of days $timediff = floor($timediff); //round down otherwise will appear one day older than actually is ?> Quote Link to comment https://forums.phpfreaks.com/topic/55072-wait-x-seconds-to-insert-data-to-mysql/#findComment-272264 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.