Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($_POST){
- //this funtion sends your secret key and the token to get a json object response
- //with info about the form submission.
- function getCaptcha($SecretKey){
- $Response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".SECRET_KEY."&response={$SecretKey}");
- $Return= json_decode($Response);
- return $Return;
- //for testing, you can run the following line to see the response from Google:
- var_dump($Response);
- }
- //here we are actually sending the info with the token...
- $Return=getCaptcha($_POST[g-recaptcha-response]);
- //if the return is success and the score is over 0.5 run your code!
- if($Return->success == true && $Return->score > 0.5){
- //run your code here when submission is NOT a BOT...
- } else {
- echo "you are a bot and the world hates you";
- }
- }
Add Comment
Please, Sign In to add comment