On my site I submit a form for entering a visitor. No login required. I can not require a login. Therefore, anyone who views the site can submit the form. He also opens the form to bots. I need to prevent bots. I asked a question on the following topic.
Unwanted entry of garbage from bots?
I got a helpful answer. I read several solutions for this (captcha and non-captcha).
Mine is not a site where I get significant traffic. My users are not very smart. So I was thinking of doing something like this. I am not a very experienced programmer, and what I say here can be very stupid. But I'm just trying to learn, so please bear with me.
Every time I submit a form, I generate a unique key (unix time + remote host IP). I store the key in the db table and I submit the form with the key being the hidden field in the form. When the form is submitted, I check if the value for the key is in the db table. If so, I delete the key from the db table and process the form. If the key is not in the db table, I drop the form and ask the user to perform the operation again.
Each time I submit, I also delete the obsolete entries (when users did not submit the form at the agreed time). I will need to have some mechanism where I prevent form requests from bots. Say, for example, if I have n number of pending requests from a specific host, I ask people to request a form in a few moments.
Will there be something like this work?
source share