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
| Layer | Stops | User friction |
|---|---|---|
| Honeypot field | Simple bots | None |
| Minimum time check (e.g. 3 seconds) | Bots that submit instantly | None |
| Rate limiting per IP | Floods | None for normal users |
| Content filters (links, keywords) | Commercial spam | Rare false positives |
| Invisible or privacy-friendly challenge | Smarter bots | Low |
| Image or audio CAPTCHA | Most bots | High, accessibility problems |
Honeypot and time check
<?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 → botChallenges
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.