I am trying to set the form that user cannot submit if he has not checked the captcha. Captcha must be mandatory but i am unable to do it. Any help will he highly appreciated . My piece of code is :
<form action="#" method="post">
<input type="email" name="email" placeholder="E-mail" required="">
<input type="password" name="password" placeholder="Password" required="">
<div align="center" class="g-recaptcha" data-sitekey="6LdtPmUUAAAAAFmYGrd_JI5k_bNzJD9kUNsv4zS0"
style="transform:scale(1);-webkit-transform:scale(1);transform-origin:0 0;-webkit-transform-origin:0 0;"></div>
<div class="tp">
<input type="submit" name="submit" value="Login">
</div>
</form>
The is code after submitting
if(isset($_POST['submit'])
{
$email = $_POST['email'];
$secret = "6LdtPmUUAAAAAKf_wtXpvAhHzwbG9bY-xO_-V0a-";
$ip = $_SERVER['REMOTE_ADDR'];
$captcha = $_POST['g-recaptcha-response'];
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip$ip");
$response = json_decode($response);
if($response->success)
echo "Verification Success. Your name is : $email";
else
echo "Verification failed.";
}
?>