How to integrate google captcha with php?

Today, we will discuss that how to integrate google captcha with php? There are lots of way in php to secure your form, Even you can create your own captch to secure your form. But now, we will use google captcha to secure our data. Google captcha is very to integrate as well as very easy to use for users. So lets start to integrate google captcha with php.


  • After click on the button, you will redirect on login page and after login you will redirect on the following page.


  • Now you have registered with google and google will give you two keys for using google captcha as shown in the following image.


  • In this example, i am using bootstrap so that i have included bootstrap folder “bootstrap-3.3.7“. If you want to learn about bootsrrap then you can read here “”.
  • Some google fonts have also used in this example so “fonts” folder contains the fonts.
  • recaptcha-php-1.11” This is the main php google captcha library. In this folder all the google captcha validation codes are exists.
  • functions.php“, I have created this file for running db queries and all.
  • index.php“, This is main index file.
  • style.css“, In this file i have created some custom styles for index page.

Flow of this example

  • User will open the page for registration.
  • He will have fill the all fields with captcha.
  • If he left the captcha empty of filled wrong captcha then error message will be show on the page.
  • If he fill the captcha then user will be register in database.

For database connection and queries, i am using PDO. If you want to learn about PDO then you can follow this link ‘

Download Source Code