Jump to content

Recommended Posts

Please can you advise me if this is the correct way to do a flood contoll on my database cheers.


in the database got the time in the format of

h:m:s

$time="01:30:10":

how do i do the flood so that a user can not post untill they have waited 10 mins

example of my code idear but needs help i think.
[code]
<?

$database_time="01:30:30";

$advance_minutes=date("i")+10;

$new_time=date("h:$advance_minutes:s");

if($new_time > $database_time){

let the user post data

}else{

echo "sorry please wait 10 minutes to post agin thank you!":

}

?>

[/code]








Link to comment
https://forums.phpfreaks.com/topic/15998-flood-controll-with-the-floor-statement/
Share on other sites

This should work why not cheers.
[code]
<?php

// database time.

$database_time="08:20:40";

//convert datbase time to a time stamp.

$time_stamp=strtotime($database);

// tell the time stamp the secons in a day.

$time_stamp_result=floor($time_stamp/86400);

// get the current time.
$minutes=date("h:i:s");

// put current time in a time stamp

$advance_minutes=strtotime($minutes);

// tell the time stamp 600 secons what is 10 mins more to the time.

$result=floor($advance_minutes/600);

//get the time stamp with current time.

$new_time=date("h:$result:s");

// if new time is grater then database time then submit else halt on message.

if($new_time > $time_stamp){

// post data as new time is lees then database time.

echo"let the user post data";

}else{

// halt becouse database time is more then new time.

echo "sorry please wait 10 minutes to post agin thank you!";

}

?>
[/code]
can you tell me if this is correct the $result should be 10 minutes in front am i correct.

there are 86400 seconds in a day.

and there are 600 secons for 10 minutes.

so 86400 + 600 = 87000 secons that should be 1 day and 10 mins


please help cheers.

[code]
<?php

$time_know=date("h:i:s");

$result_know=strtotime($time_know);

$result=floor($result_know/87000);

echo "<br>$result<br>";

?>

[/code]
does not make sence as the time stamp is correct
[code]
<?php

$database_time="09:40:22";

$result=strtotime($database_time);


$result_database=floor($result/86400);


echo "<br>$result_database<br>";



$time_know=date("h:i:s");
echo $time_know;

$result_know=strtotime($time_know);

$result=floor($result_know/87000);

echo "<br>$result<br>";

?>
[/code]

result.
[code]
13359 // time stamp from database as above.

09:45:09 // echoed time for know as above

13267 // time stamp should be 10 minutes in front as above 87000 secons

as you can see the timestamp tacken away not added the 10 minutes.
[/code]
i think i got it not sure theo


does it look correct.

[code]
<?php

$database_time="09:52:22";

$result=strtotime($database_time);


$result_database=floor($result/86400);


echo "<br>$result_database<br>";



$time_know=date("h:i:s");
echo $time_know;

$result_know=strtotime($time_know);

$result=floor($result_know/86400)+600;

echo "<br>$result<br>";

?>
[/code]


[code]
13359 time from database as above

13959 time from above with 10 minutes in front

[/code]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.