Last active
February 7, 2021 14:39
-
-
Save josephilipraja/3ec08844e9b3ec5acb9f044e3c4ec387 to your computer and use it in GitHub Desktop.
Simple PHP Server-side verification of Google re-Captcha.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])): | |
// Your site secret key obtained from Google | |
$secret = '#####################################'; | |
$grResponse = $_POST['g-recaptcha-response']; | |
// Verify with Google Servers | |
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$grResponse); | |
$responseData = json_decode($verifyResponse); | |
if($responseData->success): | |
// VERIFICATION SUCCESS | |
else: | |
// VERIFICATION FAILED | |
endif; | |
else: | |
// INVALID REQUEST | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.