Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2016 01:41
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment