redarrow Posted June 19, 2006 Share Posted June 19, 2006 Can you help please.I am trying to inplerment a flood time feature,if the time is more then 1 min do somethink else wait.Somethink is wrong with $new_time wrote wrongly cheers.[code]<?$time=("h:i:s");$new_time=list( date("h") , date("i")+1 , date("s") );if( $new_time > $time ) {do somethink} else {echo "sorry you got to wait 1 min"}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/ Share on other sites More sharing options...
trq Posted June 19, 2006 Share Posted June 19, 2006 Think about what your doing here and try again. Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/#findComment-47185 Share on other sites More sharing options...
redarrow Posted June 19, 2006 Author Share Posted June 19, 2006 [!--quoteo(post=385507:date=Jun 19 2006, 03:34 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 19 2006, 03:34 AM) [snapback]385507[/snapback][/div][div class=\'quotemain\'][!--quotec--]Think about what your doing here and try again.[/quote]Is that correct dont know lol cheers.[code]<?$time=date("h:i:s");$new_time=date("i")+1;if( $new_time > $time ) {do somethink} else {echo "sorry you got to wait 1 min"}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/#findComment-47190 Share on other sites More sharing options...
redarrow Posted June 19, 2006 Author Share Posted June 19, 2006 This example works in minites but not in full time.[code]<?$time=date("i");$new_time=date("i")+1;if($new_time > $time) {echo"do somethink";} else {echo "sorry you got to wait 1 min";}?>[/code]how can i add +1 to i in this format cheers[code]<?$time=date("h:i:s");//here ("h:i:+1s") wont let me add the 1 to i how lol,$new_time=date("i")+1;if($new_time > $time) {echo"do somethink";} else {echo "sorry you got to wait 1 min";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/#findComment-47195 Share on other sites More sharing options...
redarrow Posted June 19, 2006 Author Share Posted June 19, 2006 [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--][code]<?$time=date("h:i:s");$a=date("i")+1;$new_time=date("h:$a:s");if($new_time > $time) {echo"do somethink";} else {echo "sorry you got to wait 1 min";exit;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/#findComment-47211 Share on other sites More sharing options...
radalin Posted June 19, 2006 Share Posted June 19, 2006 I'm curious if this code can really get to the else section!!!??? Let me guess. You assign a time variable with date function. And then you assign an another time variable with one minute later. And you check if the new time (which is 1 minute higher then the old one) is bigger then the old time! Can this code get to the else section?And also you will get a 60th min if the post is at the 59th min! Just read carefully the date function because what you define in ' " ' is the format of the date! Use date("m-d-Y",mktime(blabla)) to define a newer date.Still this function can't control the time problem. It should get from somewhere the last operation time to be able to check the time interval between the old calling of the file and the new one!Long story short I think that your code should be something like:[code]if ( date("h:a:s") - $_GET['oldtime'] < 1 ){echo "please wait a minute";exit();}else{echo "dosomething";}[/code]Just think the logic of your code a little bit too. Quote Link to comment https://forums.phpfreaks.com/topic/12348-flood-controll-help-cheers/#findComment-47231 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.