How to define a minimum time interval between database inserts?

Asked

Viewed 52 times

1

I have a submission form, where you add comments to the database and show them on the page.

The problem is, I want to draw up a form so people can only make submissions every 10 minutes. That is, a user can only post a second comment 10 minutes after posting the first.

How can I do that?

This is how my submission begins:

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']);

     ...
}

The structure of the table comentarios:

 | id_steam (users) | title | comment | date |
  • Welcome to [en.so]. I advise you to first do the [tour] through the system to understand clearly how everything works and thus avoid any possible future inconvenience. As to the question, is there a better way to go into detail? Do you want the form to be available on the page every 10 minutes for all users? If so, how long will he be available? Or you want each user to be able to submit a comment every 10 minutes (if I comment now, I can only comment again after 10 minutes)?

  • Yes exactly, each user can only comment every 10 minutes after the comment made.

  • If you are the same user as the question, do not use the answer area for additional comments. Just below the question is the comment area that has this end.

  • One solution idea is: before you enter the new comment in the database, check the value of the date/time of the last comment made by the user. If there is a difference of this value to the current value of more than 10 minutes, you proceed with insertion, but otherwise you display an alert message. For that, it would be.

  • I’m sorry to be creating answers like this, but I just can’t record it right now, so I’ll register it later. I would ask you to help yourself this way for now... well... Table Comments: | id_steam (users) | title | comment | date | How will I perform this verification?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.