Free, independent guides since 2010

Security & privacy

Stopping form spam without annoying visitors

How to protect contact forms, comments and sign-ups against spam bots: honeypots, time checks, rate limiting, privacy-friendly challenges, content filters and double opt-in.

<guide section="Security & privacy" type="article" read="1 min"/>

Spam through your forms wastes time, floods your inbox and can damage your email reputation. Luckily, a few layers stop almost all of it. The technical base is in a secure PHP contact form.

Layered protection

LayerStopsUser friction
Honeypot fieldSimple botsNone
Minimum time check (e.g. 3 seconds)Bots that submit instantlyNone
Rate limiting per IPFloodsNone for normal users
Content filters (links, keywords)Commercial spamRare false positives
Invisible or privacy-friendly challengeSmarter botsLow
Image or audio CAPTCHAMost botsHigh, accessibility problems

Honeypot and time check

PHP
<?php
// in the form: <input type="hidden" name="t" value="<?= time() ?>">
// plus a hidden text field "website" that people never see
if (!empty($_POST['website'])) exit;                       // honeypot filled → bot
if (time() - (int)($_POST['t'] ?? 0) < 3) exit;             // too fast → bot

Challenges

Modern challenge services, such as Cloudflare Turnstile and similar tools, check the browser in the background and rarely show a puzzle. Check what data they process and mention them in your privacy statement (see cookie consent).

Newsletter sign-ups

  • Use double opt-in: the subscription only becomes active after a confirmation click.
  • Do not show detailed error messages that reveal whether an address exists.
  • Rate limit sign-up endpoints.

Comments

  • Moderate first-time commenters.
  • Close comments on old posts.
  • Limit the number of links per comment.

Frequently asked questions

Are CAPTCHAs bad for accessibility?

Classic image or audio puzzles are a real barrier for many people. Prefer invisible checks or challenges that offer accessible alternatives.

Why do I get spam in my newsletter list?

Bots sign up with stolen addresses to flood those inboxes. Double opt-in keeps your list clean and protects your email reputation.