PHP Google reCAPTCHA Validation Before Submit

PHP Google reCAPTCHA Validation Before Submit

In this Post We Will Explain About is PHP Google reCAPTCHA Validation Before Submit With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Google’s No CAPTCHA reCAPTCHA PHP Code ExampleExample

In this post we will show you Best way to implement google new recaptcha using php, hear for google recaptcha php localhostwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.




Also Read :   jQuery DataTables Customisation Example - Filter-Searchbox

Generate Google Site Key and Secret

we required to create or generate google site Auth key and Auth user secret key. If We don’t have any website generate site key and API secret key then We can simple create from here.as well as First of all sample click on this offical link : Recaptcha Admin

And then click We can see simple bellow view and We need simple register your web-site link this Best way:

Google Recaptcha – index.php

<html lang="en">
<head>
  <title>Step by step PHP - Google recaptcha source code example</title>
  <script src="jquery.js"></script>
  <script src='https://www.google.com/recaptcha/api.js'></script>
  <link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>

<div class="container">
  <div class="row">
        <div class="col-xs-8">
            <div class="panel panel-primary">
                <div class="panel-heading"><strong>Live24u.com Contact US Form with Google Recaptcha</strong></div>
                <div class="panel-body">
                  <form action="do_process.php" class="form-horizontal" method="POST">

                    <div class="form-group">
                        <label class="col-xs-4 control-label">Full Name:</label>
                        <div class="col-xs-6">
                          <input type="text" class="live-form" name="name" placeholder="Enter your Good Full Name" required="" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-4 control-label">Your valid Email:</label>
                        <div class="col-xs-6">
                          <input type="text" class="live-form" name="email" placeholder="Enter  your valide Email" required="" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-4 control-label">comments:</label>
                        <div class="col-xs-6">
                          <textarea type="text" class="live-form" name="comments" placeholder="Enter Your comments" required=""></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-4 control-label">Simple Captcha:</label>
                        <div class="col-xs-6">
                          <div class="g-recaptcha" data-sitekey="Put your site key here"></div>
                    </div>

                    <div class="form-group">
                        <div class="col-xs-6 col-xs-offset-6" class="live-center">  
                          <br/>
                          <input class="btn btn-success" type="submit" name="submit" value="Submit">
                        </div>
                    </div>

                 
                  </form>
                </div>
            </div>
        </div>
  </div>
</div>

</body>
</html>

Google Recaptcha – do_process.php

<?php

if($_SERVER["REQUEST_METHOD"] === "POST")
{

    $google_recpachscrkey = "Google Secret KEY HERE PUT";
    $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$google_recpachscrkey."&response=".$_POST['g-recaptcha-response']);
    $response = json_decode($response, true);

    if($response["success"] === true){
        echo "USER Form Submit Successfully.";
    }else{
        echo "You Simple are a robot";
    }

}





Example

Also Read :   PHP Get Dropdown list of all Timezones

I hope you have Got What is Google’s No CAPTCHA reCAPTCHA PHP Code Example And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.