ApeirogonGames Posted May 13, 2017 Share Posted May 13, 2017 Hey guys. I recently purchased a website template from ThemeForest and it uses Mailchimp.php to send mail via the contact form. Unfortunately it doesn't have a recaptcha integrated and I'm getting about a dozen spam form submits a day. I was trying to integrate google's recaptcha into the form, but I haven't been able to get it to work. I followed the instructions that google provided but they're obviously above my head. They made it seem so easy, but when I tried to add it in, the form just gets stuck in a loop trying to send. They say to create a php file called verify.php with this code: <?php require_once('recaptchalib.php'); $privatekey = "your_private_key"; $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 ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification } ?> and my template uses a file called send-email.php so I'm guessing all I have to do is call the send-email.php file in the section that says "Your code here to handle a successful verification" but I have no idea how to do that. Thanks so much for any help! Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted May 13, 2017 Share Posted May 13, 2017 I don't know where you got your information from, but reCAPTCHA 1.0 (the version you're trying to use) has been abandoned many years ago. The official documentation has a big red warning sign explicitly saying that. So it's no surprise that none of this works. The current version is reCAPTCHA V2 (read the manual on how verification works). There's also the new Invisible reCAPTCHA. Quote Link to comment Share on other sites More sharing options...
ApeirogonGames Posted May 14, 2017 Author Share Posted May 14, 2017 (edited) From the google Recaptcha website. https://developers.google.com/recaptcha/intro I meant to say that I don't know what I'm doing. All I know is that the current website template that I'm using utilizes php and I have no idea how to get my recaptcha working with it. Edited May 14, 2017 by ApeirogonGames Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted May 14, 2017 Share Posted May 14, 2017 From the google Recaptcha website. That's not possible, because those instructions are completely different from the instructions and code you cited in your first post (which refer to a long abandoned version). Anyway, delete the code and stay away from wherever you got it from. The current instructions tell you to make a POST request to https://www.google.com/recaptcha/api/siteverify with the parameters secret (which you got during registration), response (the value from the reCAPTCHA form field) and optionally remoteip (the user's IP address). And that's what you'll have to do. If you don't have an HTTP library yet, use cURL. There are several examples for making a POST request. Quote Link to comment Share on other sites More sharing options...
ApeirogonGames Posted May 14, 2017 Author Share Posted May 14, 2017 The code I posted is the send mail php code from the website template. I didn't post the recaptcha code. Maybe I should just look into a free form mailing program, it might be easier and likely to stay up to date with the current apis. I think this is probably too far above my skill level to implement. Thanks for the help though Jacques. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted May 14, 2017 Share Posted May 14, 2017 Um, what? You've posted the exact reCAPTCHA 1.0 example code. Look: You haven't posted any e-mail-related code, and I have no idea how that would help you resurrect the old reCAPTCHA code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.