Honeypot implementation

荒凉一梦 提交于 2019-12-03 03:52:48

In my opinion, a honeypot should consist of ALL of the below:

  • A field hidden by CSS
  • A field hidden by JavaScript
  • A field requiring a blank input
  • A field requiring a specific input

For instance:

<div class="input-field">
  Please leave this blank
  <input type="text" name="contact" value="" />
</div>
<div class="text-field">
  Please do not change this field
  <input type="text" name="email" value="your@email.com" />
</div>

Using CSS, hide the first field:

.input-field { display: none; }

Using jQuery, hide the second field:

$('.text-field').hide();
// or
$('.text-field').addClass('hide');

Then a couple of very simple checks in PHP:

if($_POST['contact'] == '' && $_POST['email'] == 'your@email.com') {
  // Not a bot
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!