Skip to content
  • Home
  • Blog
    • yttags
    • Youtube
  • Categories
  • Tools
  • Server-Side
    • php
    • Node.js
    • ASP.NET
    • Magento
    • Codeigniter
    • Laravel
    • Yii
  • JS
    • AngularJS
    • Ajax
    • VueJs
    • jQuery
    • ReactJS
    • JavaScript
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us
Pakainfo

Pakainfo

Web Development & Good Online education

how to add captcha in php registration form?

March 2, 2021 Pakainfo php, JavaScript, jQuery Leave a comment
Rate this post

Today, We want to share with you how to add captcha in php registration form.In this post we will show you To add the Google CAPTCHA in PHP HTML Form, hear for how to integrate or add google captcha in PHP HTML forms(registrations, login, contact form). we will give you demo and example for implement.In this post, we will learn about captcha code in php with an example.

Free Live Chat for Any Issue

Implementation of Captcha in Registration Form in PHP

And using the captcha with PHP html forms, you can easily validate your contact, registrations, login and other form data in PHP.

  • Step 1: Create Table In DB by Sql Query
  • Step 2: Create a Database Connection PHP File
  • Step 3: Register your website on Google Re captcha and Get All Details
  • Step 4: Create User Registrations Form with Captcha Validation In PHP
  • Step 5: Create PHP File to Check Captcha and Save User Details
Read Also:  Simple PHP Convert Object To An Array Examples

PHP Google reCAPTCHA Validation Before Submit
PHP Google reCAPTCHA Validation Before Submit

Step 1: Create Table In DB by Sql Query
CREATE TABLE `members` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  `email` varchar(100) NOT NULL,
  `password` varchar(250) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Step 2: Create a Database Connection PHP File

<?php
    $servername='localhost';
    $username='root';
    $password='';
    $dbname = "pakainfo_v1";
    $conn=mysqli_connect($servername,$username,$password,"$dbname");
      if(!$conn){
          die('sorry, Could not Connect MySql Server:' .mysql_error());
        }
?>

Step 3: Register your website on Google Re captcha and Get All Details

To here add google recaptcha to your online website you need to register/signup your online blog or website here Google captcha. And Then get your site key and secret key.about:blank : https://www.google.com/recaptcha/admin

How to Create CAPTCHA image verification using PHP and jQuery
How to Create CAPTCHA image verification using PHP and jQuery

Step 4: Make User Registration Form with Captcha Validation In PHP

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>How to Add Captcha in PHP Registrations Form - www.pakainfo.com</title>
        <!-- CSS -->
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
        <script src="https://www.google.com/recaptcha/api.js" async defer></script>
    </head>
<body>
<div class="container mt-5">
    <div class="card">
        <div class="card-header text-center">
            Add Google Captcha in PHP Registration Form - www.pakainfo.com
        </div>
        <div class="card-body">
            <form action="validate-captcha.php" method="post">
                <div class="form-group">
                    <label for="exampleInputEmail1">Mmeber Name</label>
                    <input type="text" name="name" class="form-control" id="name" required="">
                </div>                                
                <div class="form-group">
                    <label for="exampleInputEmail1">Mmeber Email address</label>
                    <input type="email" name="email" class="form-control" id="email" aria-describedby="emailHelp" required="">
                    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail1">Mmeber Password</label>
                    <input type="password" name="password" class="form-control" id="password" required="">
                </div>                   
                <div class="form-group">
                    <label for="exampleInputEmail1">Mmeber Confirm Password</label>
                    <input type="password" name="cpassword" class="form-control" id="cpassword" required="">
                </div>   
                <div class="g-recaptcha" data-sitekey="Your PUT Site Key"></div>
                <input type="submit" name="password-reset-token" class="btn btn-primary">
            </form>
        </div>
    </div>
</div>
</body>
</html>

Ajax Contact Form with Captcha reCAPTCHA v2 2.0 using PHP with jQuery
Ajax Contact Form with Captcha reCAPTCHA v2 2.0 using PHP with jQuery

Step 5: Create PHP File to Check Captcha and Save User Details
<?php
if(isset($_POST['submit']) && $_POST['g-recaptcha-response']!="")
{
    include "db.php";
    $secret = 'You PUT Site Key';
    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
    $responseData = json_decode($verifyResponse);
    if($responseData->success)
    {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $pass = $_POST['password'];
        mysqli_query($conn, "INSERT INTO members(name, email ,password) VALUES('" . $_POST['name'] . "', '" . $_POST['email'] . "', '" . md5($_POST['password']) . "')");
        echo "User registration form with captcha validation has been successfully saved";
    }
}

Download

I hope you get an idea about how to create captcha image verification in php and jquery?.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Laravel 5.7 Routing Required Parameter

Related posts:

  1. How to Add Captcha in PHP Registration Form?
  2. PHP Google No CAPTCHA reCAPTCHA jQuery Ajax
  3. Ajax Contact Form with Captcha reCAPTCHA v2/2.0 using PHP with jQuery
  4. How to Create CAPTCHA image verification using PHP and jQuery
  5. integration Google No CAPTCHA reCAPTCHA using Laravel
  6. how to add captcha in login form in codeigniter?
  7. Simple PHP Create Custom Captcha Generator
  8. How to Integrate Google No CAPTCHA reCAPTCHA using VueJS
  9. PHP Google reCAPTCHA Validation Before Submit
  10. how to implement custom captcha code in php Script?
Read Also:  PHP Simple Image Upload and Display Source Code
add google captcha in php formhow to add captcha in html formhow to add captcha in php contact formhow to add captcha in php login formhow to add google captcha in php registration formhow to create captcha image verification in php and jqueryhow to implement custom captcha in phpsimple captcha code in php

Post navigation

Previous Post:How to Refresh / Reload a Component and Page in React?
Next Post:Bootstrap datepicker disable past dates Example

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me
Cricday

Categories

3movierulz (48) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (92) Codeigniter (174) CSS (96) Earn Money (61) Education (53) Entertainment (108) fullform (77) Google Adsense (62) Highcharts (77) Hollywood (93) JavaScript (1354) Jobs (39) jQuery (1421) Laravel (1083) LifeStyle (50) movierulz4 (47) Mysql (1029) Mysqli (890) Node.js (38) php (2110) Programming (2320) Python (96) ReactJS (37) Software (102) Software (77) Stories (78) tamilrockers (88) Tamilrockers kannada (48) Tamilrockers telugu (47) Tech (102) Technology (2359) Tips and Tricks (107) Tools (112) Top10 (295) Trading (50) Trending (45) VueJs (250) Web Technology (83) webtools (129) wordpress (165) World (123)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

Web Development & Good Online education : Pakainfo by Pakainfo.
Top
Subscribe On YouTube : Download Source Code & New itsolutionstuck
We accept paid guest Posting on our Site : Guest Post Chat with Us On WhatsApp