Hi all,
I was using recaptcha v1 perfectly well but am having issues getting V 2 working. My form submissions are handled by Form2Mail and previously I simply added the following php at the beginning of the Form2mail.php file and all worked.
<?php
require_once('recaptchalib.php');
$privatekey = "####################";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("Sorry the reCAPTCHA verification wasn't entered correctly. Please go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
?>
Now using V2 the above code no longer works, if I add the following code to the head of my html page containing the form it all works but I dont want to have the code at the top of my html page as it becomes visible to anyone who does a simple view source.
<?php
if(isset($_POST['submit'])){
$privatekey = "################";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
?>
I am not a php programmer so would appreciate any help anyone can give to advise what I need to do to have the verification and private key back in the form2mail.php file again.
Thanks in advance for any help provided.