· 7 years ago · Jul 02, 2018, 09:10 AM
1<?php
2 if ( isset($_POST['envia']) && $_POST['envia'] == 'ok' ) {
3 $post = $_POST;
4 $result = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, stream_context_create( array(
5 'http' => array(
6 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
7 'method' => 'POST',
8 'content' => http_build_query( array(
9 'response' => $_POST['g-recaptcha-response'],
10 'secret' => 'secret_key'
11 ) ),
12 ),
13 ) ) );
14 $result = json_decode($result);
15 var_dump( $result->success );
16 // if everything's okay use your $post
17 }
18?>