<?php
if
(isset(
$_POST
[
'g-recaptcha-response'
])) {
$secret_key
=
'YOUR_SECRET_KEY'
;
$curl
= curl_init();
curl_setopt(
$curl
, CURLOPT_URL,
$url
);
curl_setopt(
$curl
, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$curl
, CURLOPT_HEADER, false);
$data
= curl_exec(
$curl
);
curl_close(
$curl
);
$responseCaptchaData
= json_decode(
$data
);
if
(
$responseCaptchaData
->success) {
echo
'Captcha verified'
;
}
else
{
echo
'Verification failed'
;
}
}
?>
<form method=
"post"
id=
"userForm"
>
<p><input type=
"text"
class
=
"form-control"
name=
"fullname"
placeholder=
"Enter full name"
/></p>
<p><button
class
=
"g-recaptcha btn btn-primary"
data-sitekey=
"YOUR_SITE_KEY"
data-callback=
"submitForm"
>Submit</button></p>
</form>
<script>
function
submitForm() {
document.getElementById(
'userForm'
).submit();
}
</script>