How to Add Google Captcha in PHP Registration Form
Use the below given easy steps to add captach in PHP html forms(registration, login, contact etc.):
- Create Table In DB by Sql Query
- Create Database Connection PHP File
- Register your website on Google Re captcha and Get All Details
- Create User Registration Form with Captcha Validation In PHP
- Create PHP File to Check Captcha and Save User Details
Step 1: Create Table In DB by Sql Query
First of all, open your phpmyadmin and run the following sql query. To create table into your selected database:
Step 2: Create a Database Connection PHP File
In this step, create a file name db.php and add the following code into db.php file:
Step 3: Register your website on Google Re captcha and Get All Details
To add google recaptcha to your website you need to register your website here https://www.google.com/recaptcha/admin. Then get your site key and secret key.about:blank
Step 4: Create User Registration Form with Captcha Validation In PHP
In this step, create user registration form that named registration.php and add google captcha validation.
So, open registration.php and add the following code into it:
Step 5: Create PHP File to Check Captcha and Save User Details
Now, create validate-captcha.php file and add the following code into your validate-captcha.php file.
The validate-captcha.php file code will validate your captach and then store user registration data into database table.
Output