Reputation: 33
I've got a form system that submits to the db
The problem is that I want to define the form so that people can only do submissions every 10 minutes. That is, a user can only publish a second comment 10 minutes after the first one has been published. How can I do this?
Script Starts like this:
if(isset($_POST['submitPost'])) {
//mysqli_real_escape_string($db, )
$postcomment = mysqli_real_escape_string($db, $_POST['message']);
$uploaded = mysqli_real_escape_string($db, $_POST['upload']);
$titleID = mysqli_real_escape_string($db, $_POST['title']);
...
}
Table comments
:
| id_steam (users) | title | comment | date |
Upvotes: 0
Views: 35
Reputation: 372
What I would do is this:
Users have to be logged in so you need a login, otherwise they are hard to track, yes you can use cookies but you can avoid anyway. The same counts for sessions when not logged in.
When users are logged in then you can store in the session what the last time was when the responded on some topic (assuming you don't have a zillion topics to respond on). You can check in your database which user responded on which topic.
As you can see your problem is not as simple as checking a post request. If I was you I would also check if you want to use a framework like Laravel (which is excellent for beginners) for this. A framework will help you with these tasks.
That is the best advice I can give.
Upvotes: 1