The most effective way to protect your website from spam comments, fake memberships and brute-force attacks. Google reCAPTCHA, distinguishes real users from bots with its advanced risk analysis engine.
In this guide; classic "I am not a robot" (v2) box and completely invisible Points Based (v3) You will find the differences of the system, how to integrate it with PHP and best security practices.
reCAPTCHA
Privacy - Terms
Keep contact forms and comment areas clean.
Save users from solving puzzles with v3.
Installation in minutes with PHP, JS and HTML.
It uses Google's advanced risk analysis engine.
Websites are subject to millions of bot attacks every day. These boots; They can fill contact forms with spam messages, open fake records in membership systems, perform brute-force attacks or steal your content (scraping).
Google reCAPTCHAprotects your site against these threats by analyzing billions of transactions. It perfectly distinguishes between "human" and "robot" with advanced algorithms running in the background, without disrupting the user experience.
Main differences and uses between the two versions
It asks the user to check the "I am not a robot" box. Creates a picture selection puzzle in questionable situations.
The user does nothing. It runs in the background and gives the user a "Score" between 0.0 and 1.0 .
Register your site via Google Admin Console
Google reCAPTCHA Admin Go to the panel and add a new site by pressing the "+" button.
Enter a Label. Select v2 (Challenge) or v3 (Score based) from the "reCAPTCHA type" section. Generally the v2 "I'm not a robot" checkbox is the most common.
In the "Domains" section, you can enter the address of your site (eg: ekasunucu.com) and for testing localhost add.
You will be given two keys:
Use the codes below to add reCAPTCHA to your site
<html>
<head>
<!-- Google API Scriptini Ekleyin -->
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<form action="kontrol.php" method="POST">
<input type="text" name="adsoyad" placeholder="Adınız" required><br>
<input type="email" name="email" placeholder="E-posta" required><br>
<!-- reCAPTCHA Kutucuğu -->
<!-- data-sitekey kısmına Google'dan aldığınız Site Key'i yazın -->
<div class="g-recaptcha" data-sitekey="SITE_KEY_BURAYA"></div>
<br>
<input type="submit" value="Gönder">
</form>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Formdan gelen recaptcha verisi
$recaptcha_response = $_POST['g-recaptcha-response'];
// Google'dan aldığınız GİZLİ ANAHTAR (Secret Key)
$secret_key = "SECRET_KEY_BURAYA";
// Correctlama URL'si
$verify_url = "https://www.google.com/recaptcha/api/siteverify";
// POST verisi hazırlama
$data = [
'secret' => $secret_key,
'response' => $recaptcha_response,
'remoteip' => $_SERVER['REMOTE_ADDR']
];
// CURL ile Google'a sorma (Daha secure ve hızlı)
$ch = curl_init($verify_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// JSON yanıtı çözme
$result = json_decode($response, true);
if ($result['success']) {
// Correctlama Başarılı! Operations yapabilirsiniz.
$adsoyad = htmlspecialchars($_POST['adsoyad']);
echo "Teşekkürler $adsoyad, correctlama başarılı.";
} else {
// Correctlama Failed!
// Error kodlarını görebilirsiniz: print_r($result['error-codes']);
echo "Please robot olmadığınızı verify.";
}
}
?>
<script src="https://www.google.com/recaptcha/api.js?render=SITE_KEY_BURAYA"></script>
<script>
function formGonder() {
grecaptcha.ready(function() {
// 'submit' aksiyonu for token al
grecaptcha.execute('SITE_KEY_BURAYA', {action: 'submit'}).then(function(token) {
// Token'ı gizli inputa yaz ve formu gönder
document.getElementById('g-recaptcha-response').value = token;
document.getElementById('myForm').submit();
});
});
}
</script>
<form id="myForm" action="kontrol_v3.php" method="POST">
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response">
<!-- Other inputlar -->
<button type="button" onclick="formGonder()">Gönder</button>
</form>
* Also on v3 PHP side $result['score'] must be checked (Ex: if score > 0.5 , accept).
Armor your site against bots with the Eka Sunucu team
Basic installation support for our customers who receive hosting or VDS service from Eka Sunucu.
Professional v3 integration for your custom software projects, PHP scripts or corporate systems.
Technical details about reCAPTCHA integration
No, the standard version of Google reCAPTCHA is completely free for up to 1 million transactions per month. This limit is more than enough for most websites. Enterprise edition is available for very high traffic sites.
Yes, reCAPTCHA works on localhost. When adding a domain from the admin panel localhost or 127.0.0.1 You can make your developments in the test environment by typing.
This error indicates that the domain address of the website where you run the reCAPTCHA code (eg: ekaservucu.com) has not been added to the "Domains" list in the Google Admin panel. Check the panel and add your domain.
v3 returns a score between 0.0 and 1.0 . 1.0 definitely means human, 0.0 definitely means bot. Generally, 0.5 score is used as the threshold value. You can block transactions below 0.5 or request additional verification.
Protect your site from bots with Eka Sunucu's secure hosting infrastructure and expert support. Rent a server now and grow safely.