close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

spam being received with no referrer in the email log

Thread began 12/04/2020 10:00 am by MagsW | Last modified 12/14/2020 11:16 am by MagsW | 44 views | 15 replies

MagsW

I think I've now got this working, so I thought I would post my solution in case it helps anyone else trying to work out how to integrate Google reCaptcha v3 with Universal Email. I save these blocks as Snippets in Dreamweaver so that I can easily add them to pages.

First, generate your SITEKEY and SECRET KEY from Google reCaptcha.

Add your email script to the page first because it won't be available from the Server behaviors once the reCaptcha code is added.

Insert the following after the WA_Email.php include, changing SECRET_KEY to your own secret key. You can also change the sensitivity of the reCaptcha (0.5 is the default, 0.1 is a bot and 0.9 is a human).

<?php // Check if form was submitted:
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {
// Build POST request:
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_secret = 'SECRET_KEY';
$recaptcha_response = $_POST['recaptcha_response'];
// Make and decode POST request:
$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha);
// Take action based on the score returned:
if (($recaptcha->score >= 0.5) && (isset($_POST["submit"]) || isset($_POST["submit_x"])))
{

//Insert your WA Universal Email Code block here

} else {
echo("Spam test failed");
}
} ?>



Call the JS in the head of your document, changing SITEKEY to your own Site Key:

<script src="https://www.google.com/recaptcha/api.js?render=SITEKEY"></script>
<script>
grecaptcha.ready(function () {
grecaptcha.execute('SITEKEY', { action: '' }).then(function (token) {
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
});
});
</script>



Add the following hidden field to your form:

<input type="hidden" name="recaptcha_response" id="recaptchaResponse">

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...