Prevent php web contact form spam

前端 未结 7 2128
面向向阳花
面向向阳花 2021-01-30 14:14

I am an amateur web designer, I have searched on stackoverflow.com and other websites and have found many fixes for this issue I\'m having, but none of them have worked (probabl

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 14:45

    Usually the bots submit a form very fast. So, based on that, another solution could be to add another hidden field that contain the number of seconds that passed from when the page was oppened. This can be done using JavaScript. Then check it in PHP. If the number of seconds is smaller than 5 seconds then it's spam (It's more likely that the real client needs more time to fit the form). You can adjust the number of seconds based on how many fields the form contain.

提交回复
热议问题