Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple implementation of Google's reCAPTCHA in PHP. Use this to simply check if the CAPTCHA was correctly solved by the user. Make sure you replace the key value with your secret key.
// get reCAPTCHA verification code
if (isset($_POST['g-recaptcha-response'])) $captcha = $_POST['g-recaptcha-response'];
// check with Google's servers if the captcha is valid
$captchaSuccess = false;
if (isset($captcha)) {
$captchaKey = 'YOUR SECRET KEY';
$captchaURL = '';
$response = json_decode(file_get_contents($captchaURL . $captchaKey . '&response=' . $captcha));
$captchaSuccess = $response->{'success'};
// now simply check the $captchaSuccess value
You can’t perform that action at this time.