Spam is a huge problem, if you don't protect your forms with some sort of anti-spam measure, it won't be long before you are receiving a huge amount of unsolicited email. Fortunately Google has invented it's RECAPTCHA v3, which works behind the scenes, validating users. If a user is suspected of being a bot, it will show a series of images to test that the user is human. If the user fails the test, then no email is sent.
However, although the RECAPTCHA is very good at what it does, it is not trouble free. The reason I wanted to write this blog post is because I often have trouble with the RECAPTCHA, especially with new sites and actually getting it working. This blog post is written for Concrete5 / CMS but some of these concepts may apply to other website platforms too.
You try to submit a form, it doesn't submit and just shows this error instead:
Potentially it is a very serious issue leading to lost enquiries etc. We need to fix it, but what does the error mean and how do we fix it?
This error is returned from the form block controller in Concrete5:
// check captcha if activated if ($this->displayCaptcha) { $captcha = Core::make('helper/validation/captcha'); if (!$captcha->check()) { $errors['captcha'] = t('Incorrect captcha code'); $_REQUEST['ccmCaptchaCode'] = ''; } }
It's a bit generic, so we need to try various things:
Another error message that can appear is "Invalid token, please reload the page and retry".
View the source and find this line that contains ccm_token:
<input type="hidden" name="ccm_token" value="1737049893:d18369291fc5431fc45c0716ff4ae3ba" /><input type="hidden" name="express_form_id" value="f228a3ef-c117-11ee-9f35-3ab2f6b86ec1">
<div class="ccm-dashboard-express-form">
The value of that field (above it is 1737049893:d18369291fc5431fc45c0716ff4ae3ba) should change every time you refresh. If it doesn't, it is a caching issue.
So we need to check the following:
server cache like opcache
concrete cache
browser cache
3. Turn each off, refresh your browser and see if the value changes.
Strangely, on just one of the sites we host, the issue turned out to be down to the Block Output Cache setting in the CMS:
With some pain, using Google's RECAPTCHA means you can prevent the majority of spam. It won't block everything, but should bring it down to manageable levels.
Special thanks to https://www.mesuva.com/ for helping us with this article.
If you have any other tips, please email us and we'll be happy to include them and link back to your website.
Want to have your say on this topic? Start by posting your comment below...
Can we help?
We are a digital agency, specialising in web design, development, hosting and digital marketing. If you need help with anything, feel free to reach out...
04 March 2025
24 February 2025
Keep up to date