简体   繁体   中英

How can I count and limit form submission?

I have a form that submits data to a mysql database. Once the form has been submitted it reloads and the user fills in the form and submits again over and over (They are being presented with different questions each time).

I want to limit the amount of times the user can submit the form to 3 before the user is headed to another page (results). I'm not sure how to go about achieving this. I have created a counter that logs each time a user submits the form in my database (code below) but I don't know what to do now. I am not using ajax. I'd really appreciate any help.

$sql="UPDATE counter SET counter = counter + 1 WHERE id=$id";
mysqli_query($con, $sql);

Try just another condition in your update:

$sql="UPDATE counter SET counter = counter + 1 WHERE id=$id AND counter < 4";
mysqli_query($con, $sql);

But your goal is really not clear to me...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM