Last active
June 7, 2024 10:27
-
-
Save amityweb/7175c5797d96005dce11e12677364e4b to your computer and use it in GitHub Desktop.
Revisions
-
Laurence Cope renamed this gist
Jun 16, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Laurence Cope created this gist
Jun 16, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ // Add in to HTML where you want the box to be <script src='https://www.google.com/recaptcha/api.js' async defer></script> <div class="captcha_wrapper"> <div class="g-recaptcha" data-sitekey="YOUR_PUBLIC_KEY"></div> </div> // Add into PHP validation to check the submitted captcha response is a success or fail /* Google ReCaptcha Verification */ $url = 'https://www.google.com/recaptcha/api/siteverify'; $privatekey = "YOUR_PRIVATE_KEY"; $response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']); $data = json_decode($response); if (isset($data->success) AND $data->success==true) { // Do Success Stuff! } else { // Do Fail Stuff! }