Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PHP Google reCaptcha Examples
<?php
if ($_POST) {
/*
* Author : Savaş Can ALTUN <savascanaltun@gmail.com>
* Date : 28.06.2016
* Personel Page => http://savascanaltun.com.tr
* Video Example => https://www.youtube.com/watch?v=7F-vWQjbeMo
*/
$url="https://www.google.com/recaptcha/api/siteverify";
$r=$_POST['g-recaptcha-response'];
$k="SCRET_KEY";
$ip=$_SERVER['REMOTE_ADDR'];
$gidicek_adress=$url."?secret=".$k."&response=".$r."&remoteip=".$ip;
$res=file_get_contents($gidicek_adress);
$res=json_decode($res,true);
if ($res['success']) {
echo "Bot değil doğrulama başarılı";
}else{
echo "Bot tespit edildi.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Sayfası </title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form action="" method="POST">
<input type="text" placeholder="Test">
<div class="g-recaptcha" data-sitekey="SITE_KEY"></div>
<button>Gönder</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment