Skip to content

Instantly share code, notes, and snippets.

@luckydevilru
Created May 14, 2018 13:51
Show Gist options
  • Select an option

  • Save luckydevilru/9e6fd350c51b2f58a2c4a4746ef2f831 to your computer and use it in GitHub Desktop.

Select an option

Save luckydevilru/9e6fd350c51b2f58a2c4a4746ef2f831 to your computer and use it in GitHub Desktop.
google recaptcha 2
if ( !$_POST['g-recaptcha-response'] ) {
exit('Заполнить капчу');
}
$url = 'https://www.google.com/recaptcha/api/siteverify';
$key = '********************'; // секретный ключ
$query = $url.'?secret='.$key.'&response='.$_POST['g-recaptcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR'];
$datas = json_decode( file_get_contents($query) );
if ( $datas->success == false ) {
exit('Капча введена неверно');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment