Streaming live at 10am (PST)

Google Recaptcha V2 with Serverside PHP


#1

I thought this might be helpful to anyone trying to use Recatcha V2 in Webflow with a serverside PHP script for form handling. Once you sign up for Recaptcha V2 on Google’s site, you must add an embed element to your Webflow form to hold the Google code snippet. Google says to give the element a class name of ‘g-recaptcha’ but I noticed that Webflow appends ’ w-embed’ to the class name behind the scenes. This prevents the Recaptcha widget from appearing in your form. Here is what I did to get this to work:

  1. Add an embed element to your Webflow form where you want the Recaptcha widget to appear.
  2. Give the embed element a class name of ‘g-recaptcha w-embed’.
  3. Paste the Google code snippet into the embed element, and edit the code by changing the class name from ‘g-recaptcha’ to ‘g-recaptcha w-embed’, and entering your SiteKey.
  4. Edit the page (gear icon) and paste the following code inside the head tag:
    <script src="https://www.google.com/recaptcha/api.js" async defer></script>

The widget should now appear in your form (Note: You can add ‘YourSite.webflow.io’ to your Recaptcha settings in Google to make testing easier).

Next you’ll need to modify the PHP script that handles the form processing. I found the following link very helpful:

(https://www.kaplankomputing.com/blog/tutorials/recaptcha-php-demo-tutorial/)

I hope this helps!


#2

Thanks mjcasa! I’m super ignorant about how PHP scripts work but I have a real need for a recaptcha on my forms so is there any way you can help me understand how to use PHP in this context? Do I need to have special coding skills or use a host other than Webflow? Thanks in advance.

Jason