Forms on websites, such as contact, registration, reservation, and quote request forms, are indispensable components of digital interactions. However, these forms are highly susceptible to abuse by spam submissions, bots, and fake users. Especially even when reCAPTCHA is used, if spam forms are still being received, more advanced measures are necessary.
In this article, we explain more than 10 advanced security techniques that can be applied to combat fake forms, both on PHP-based sites and WordPress-based systems, step by step with example code.
Using reCAPTCHA v2 (“I’m not a robot”) or v3 (background risk analysis) reduces spam.
However, advanced bots can pass reCAPTCHA v2. Therefore, it is not sufficient on its own.
$response = $_POST['g-recaptcha-response'];
$remoteip = $_SERVER['REMOTE_ADDR'];
$secret = 'YOUR_SECRET_KEY';
$verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}&remoteip={$remoteip}");
$captcha_success = json_decode($verify);
if (!$captcha_success->success) die("Bot detection");
Hidden fields that the user does not see but bots fill in.
if (!empty($_POST['honeypot'])) {
die("Bot detection!");
}
WP Armour – Honeypot Anti Spam
Bots usually fill out the form very quickly. Applications received in less than 3 seconds can be rejected.
session_start();
if (time() - $_SESSION['form_start'] < 3) die("Sent too quickly, may be a bot");
Block the same IPs or invalid user-agents that come with a large number of forms.
if ($_SERVER['HTTP_USER_AGENT'] == '' || preg_match('/curl|bot|python/i', $_SERVER['HTTP_USER_AGENT'])) die("Bot detection");
Bots usually fill in every field. However, if logical data is not entered in optional fields, this may be spam.
If no field is left blank > suspicious
If random characters are entered in the name > suspicious
Block bots from certain countries with Cloudflare or GeoIP.
PHP GeoIP
For WordPress: iQ Block Country
An email is sent to the user after the form is submitted. No action is taken unless confirmed.
Especially recommended for quote/reservation forms.
Trigger the form submission process only with JS. Non-JS systems (bots) cannot submit.
document.querySelector("form").addEventListener("submit", function(e) {
// this check should be done on the server
});
Friendly CAPTCHA → more comfortable in terms of user experience
hCAPTCHA → more visual testing, Google reCAPTCHA alternative
For WordPress: hCaptcha for WordPress plugin
Which IPs have submitted how many times and when?
In which fields is the same data always entered?
Keep track of these by keeping logs
$log = date("Y-m-d H:i:s") . " | " . $_SERVER['REMOTE_ADDR'] . " | " . $_POST['email'] . "\n";
file_put_contents("form_log.txt", $log, FILE_APPEND);
Block if there are certain character patterns in the email, name, message fields:
if (preg_match('/(viagra|casino|win money|bit.ly|http\:|https\:)/i', $_POST['message'])) {
die("Spam content detected");
}
Akismet is WordPress's spam filtering system.
It is especially effective against comment + form spam.
Works integrated with Gravity Forms, Contact Form 7.
Provides IP-based data in addition to form field analysis
Recommended for WordPress-based corporate sites
Publish all your forms over HTTPS
Create a "Blacklist" for frequently received spam data (example emails, names)
Show your forms only to logged-in users (like WordPress comment form)
reCAPTCHA alone is not enough to protect a web form. Especially in widespread systems like WordPress, bots can target forms by exploiting plugin vulnerabilities. Therefore, it is necessary to use methods such as honeypot, time control, content analysis, and IP restriction together.
It is recommended to use at least 4-5 of the methods in this list together for a structure that will stop spam by 95% without disrupting the user experience.
Web siteniz için uygun fiyatlı Ucuz Hosting Paketleri ile yüksek performanslı barındırma hizmeti sunuyoruz.
Dijital varlığınızı güçlendirmek için profesyonel Sosyal Medya Hesap Yönetimi hizmeti sağlıyoruz.
Görsellerinizi sıkıştırmak için kullanışlı PNG to WebP dönüştürücümüzü deneyin.
Resim boyutlarını küçültmek isteyenler için JPG to WebP aracı idealdir.
SEO uyumu için Robots.txt Oluşturucu aracımızı kullanabilirsiniz.
Htaccess Oluşturucu ile yönlendirme ve erişim ayarlarınızı kolayca yapın.
Kullanıcı deneyimini artırmak için özgün UI/UX Tasarım çözümleri sunuyoruz.
Hızlı ve güvenli kurulum için WordPress hizmetimizden faydalanın.
Sitenizi arama motorlarında yükseltmek için Google Optimizasyon hizmeti sunuyoruz.
Markanızı tanıtmak için Tanıtım Yazısı içerikleri üretiyoruz.
UGC ile içerik gücünüzü artırın: UGC İçerik.
Profesyonel Yazılım Kurulum hizmetleri sunuyoruz.
Kaliteli içerik arayanlara özel Hazır Makale & İçerik Satışları.
Sıra Bulucu ile arama motoru sıralamanızı takip edin.
Google Haritalara Kayıt ile konumunuzu haritada gösterin.
Alan adı otoritenizi öğrenin: DA PA Sorgula.
Dış bağlantılarınızı analiz edin: Dış Link Aracı.
Dahili link yapınızı inceleyin: İç Link Aracı.
Arama motoru başarınızı artırmak için SEO Danışmanlığı alın.
Organik trafiğinizi artırmak için SEO çözümleri geliştirin.
Özel çözümler için Mobil Uygulama geliştirme hizmeti sunuyoruz.
Markanız için Logo tasarlıyoruz.
İşinize özel Web Yazılım çözümleri sunuyoruz.
Kurumsal imajınızı yansıtan Kurumsal Web Tasarım hizmeti.
Süreçlerinizi hızlandırmak için Bot Program geliştiriyoruz.
Online satışlarınız için Sanal POS sistemleri sunuyoruz.
Entegrasyonlar için Pazaryeri ve Kargo Entegrasyonu.
Kullanıcı deneyimi testleri için Son Kullanıcı Testleri.
İçerik indirimi için TikTok Video İndir aracı.
Görsellerinizi kolayca küçültün: Resim Boyutlandırma.
Yararlı kod örnekleri için Site Kodları rehberine göz atın.
Kodları online inceleyin: HTML Viewer.
IP adresinizi öğrenmek için IP Adresim Nedir aracını kullanın.
Bağlantı hızınızı test etmek için Hız Testi.
DNS önbellek sorunları için DNS Cache Problemi sayfasını inceleyin.
DNS değişikliklerini görmek için DNS Önizleme aracı.
IDN dönüştürme için IDN Çevirme kullanın.
Sunuculara ping atmak için Ping Gönder özelliğini deneyin.
Web sitenizin yanıt süresini test etmek için Web Site Ping aracımızı kullanın.