The code below is supposed to check to see if a user has made an addition to a MySQL database table called "submission" more than 10 times in the last day. If the answer is yes, then the user is re-redirected back to the index page. As far as I can tell, it works just fine.
How could I modify to make it do the re-direct if the user has submitted 10 or more items in the last hour?
Thanks in advance,
John
$queryuidcount = "select loginid from submission where TO_DAYS(datesubmitted) = TO_DAYS(NOW()) AND loginid = '$uid'";
$uidresult = mysql_query($queryuidcount);
if (mysql_num_rows($uidresult) >= 11)
{
session_write_close();
header("Location:http://www.domain.com/sample/index.php");
exit;
}
$queryuidcount = "select COUNT(*) from submission where datesubmitted > (NOW() - INTERVAL 1 hours) AND loginid = '$uid'";
$uidresult = mysql_query($queryuidcount);
while($row = mysql_fetch_array( $uidresult )) {
if ($row['COUNT(*)'] >= 10) {
session_write_close();
header("Location:http://www.domain.com/sample/index.php");
exit;
}
}
This code gives you a count which you can use to redirect.
If datesubmitted
is timestamp you can try something like this. -Sorry I don't have php or mysql currently installed so I hope this works.
$queryuidcount = "select COUNT(*) from submission where datesubmitted > DATE_SUB(NOW(),HOURS,1) AND loginid = '$uid'";