Kishan Kumar

Kishan Kumar

  • NA
  • 127
  • 27.4k

How to add recapcha in our website.

Feb 19 2018 12:59 AM
<html>
<head>
<title>reCAPTCHA </title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form action="captcha.php" method="POST">
<input type="email" name="email"/>
<div class="g-recaptcha" data-sitekey="6LcSH0QUAAAAAG_R_YNgzXIhKfI_WsiGYc5kYyea"></div>
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
</html>
 
 
<?php
$email;$comment;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR SECRET KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false)
{
echo '<h2>You are spammer ! Get the @$%K out</h2>';
}else
{
echo '<h2>Thanks for posting comment.</h2>';
}
?>
 
 
Some errors....
i will attach the file Please resolve now...
Thanks 
(Kishan). 
 
 
 
 
 
 

Attachment: Recpatcha.zip

Answers (1)