How do I add Honey pot fields to my forms?

后端 未结 5 2291
灰色年华
灰色年华 2020-12-17 17:31

I\'ve been reading about adding Honey pot fields to my forms for combating bots/spam. Only problem is theirs no guides or anything on where to start. Many sites say to make

5条回答
  •  长情又很酷
    2020-12-17 17:48

    HTML - 
    
    
    PHP Validation -
    if(strlen($_POST['verifyEmail']) > 0){
       header('location: {some redirect URL here..}'); //Send them way away from your form :)
    die(); //Stop execution of the script
    }
    
    CSS - 
    #verifyEmail{
    position:fixed; 
    visibility: hidden; 
    top:-500px; left:-500px;
    }
    

    dislplay: none; does not show to a bot in HTML (try it with view source) visibility: hidden; left:-500px; top:-500px; (displays when you view source)

    I used display:none honey pots for a while, then switched to visibility option when it occurred to me that the field didn't show in the source code. Do it with a class or id in CSS, not inline style. Notify users with label is good idea, and name is not so important because most bots generally fill in all fields.

    Definitely not a catch all but very effective if used with a basic math captcha.

提交回复
热议问题