In my opinion, a honeypot should consist of ALL of the following:
- CSS hidden field
- A field hidden by JavaScript.
- Field requiring blank input
- 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>
Use CSS to 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 ') {
source share