$response_code = $_POST['g-recaptcha-response'];
$array = [
'secret' => "6LcjSSYUAAAAAFCEhoFywBtCXF2fMGmLnc8cPq7v",
'response' => $response_code
];

function curl($url, $parameters){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters));
curl_setopt($ch, CURLOPT_POST, true);

$headers = [];
$headers[] = 'Content-Length: '. strlen(http_build_query($parameters));

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

return curl_exec($ch);
}

$returned = curl("https://www.google.com/recaptcha/api/siteverify",$array);

$data = json_decode($returned);
return $data->success;