Skip to content
PHP Logo

Are there alternative methods to prevent bots without using Captchas, especially reCaptcha?

One alternative method to prevent bots without using Captchas, especially reCaptcha, is to implement a honeypot technique. This involves adding a hidden field to your form that only bots would fill out, as they typically scan and complete all fields. If the hidden field is filled out, you can then block the submission.

php
// Add a hidden field to your form
<input type="hidden" name="honeypot" value="">

// Check if the honeypot field is filled out
if(!empty($_POST['honeypot'])) {
    // Block the submission
    die("Bot detected. Please try again.");
} else {
    // Process the form submission
    // Your code here
}