How to put a "CAPTCHCA" control in DFM forms to avoid spam

Forum rules
Post Reply
giosafat
Posts: 35
Joined: Sat Apr 09, 2011 4:43 pm

How to put a "CAPTCHCA" control in DFM forms to avoid spam

Post by giosafat » Mon May 27, 2013 12:16 am

Here's how to insert a "CAPTCHCA" control in a form made with DFM2HTML (see attached image):
- go to http://www.google.com/recaptcha and log-in with user and password of your google user account (or create one if you haven't one)
- go to "my account" and input your site's domain, then click on "create key" on the bottom of the page
- now, in your DFM2HTML project, create your form using "tools - presets - php" and modify as you want
- enlarge in height the external frame of the form (object named "Page1" or similar) and the internal one (object named "HTMLForm1" or similar) so that between the last field of the form and the "submit" button, you get an empty area (about 200px in height)
- inside the "HTMLForm1", in the just created empty area, put an "HTML/script" object containing this code:
<?php
require_once('recaptchalib.php');
$publickey = "your_public_key"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>

- replace "your_public_key" with the public key obtained in your re-captcha account (second step) maintaining the quotes
- click on the "page control" object of the form and go to the second page of the form ("page2" or similar)
- click on the first "HTML/script" object and write your email address (as usual) in place of "your@email.com" maintaining the quotes
- immediately after the opening tag (<?php) put this code:
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 replace "your_private_key" with the private key obtained in your re-captcha account (second step) maintaining the quotes
- upload in the root of your domain all the generated pages
- download the zip file from here: https://code.google.com/p/recaptcha/dow ... lib-Latest
- extract only the file "recaptchalib.php" and upload it in the root of your domain.
That's all...
You do not have the required permissions to view the files attached to this post.

reuterr
Posts: 253
Joined: Sat Jul 24, 2010 9:59 am

Re: How to put a "CAPTCHCA" control in DFM forms to avoid sp

Post by reuterr » Fri May 31, 2013 10:24 am

Thanks Giorgio!!!
I'll keep this in mind just in case someone in the German forum, who's English might not be good enough, needs this procedure to be translated.
All the best,
Roland

Post Reply

Return to “English Forum”