PHP form - with validation honeypot

落爺英雄遲暮 提交于 2019-12-03 21:16:32

Honeypots work best if they have a field name that sounds legit, they should also be hidden using javascript to change the css after the page loads. (Most) bots don't have javascript enabled so they cannot process that this field should not be filled out.

I use something like this:

<div class='req'>
    <label for='website'>Leave blank</label>
    <input type='text' name='website'>
</div>

Hide it with jquery:

$(document).ready(function(){
    $(".req").hide();
});

reject it server side if the field is filled out with something like this

if($_POST['website'] != ''){
    echo "It appears you are a bot!";
}
else{
//process the rest of the form
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!