how to add recaptcha validation in php

index.html

<html>
  <head>
    <title>Google recapcha demo - Codeforgeek</title>
    <script src='https://www.google.com/recaptcha/api.js'></script>
  </head>
  <body>
    <h1>Google reCAPTHA Demo</h1>
    <form id="comment_form" action="form.php" method="post">
      <input type="email" placeholder="Type your email" size="40"><br><br>
      <textarea name="comment" rows="8" cols="39"></textarea><br><br>
      <input type="submit" name="submit" value="Post comment"><br><br>
      <div class="g-recaptcha" data-sitekey="=== Your site key ==="></div>
    </form>
  </body>
</html>
verify.php

<?php
    $email; $comment; $captcha;

    if(isset($_POST['email']))
        $email=$_POST['email'];
    if(isset($_POST['comment']))
        $comment=$_POST['comment'];
    if(isset($_POST['g-recaptcha-response']))
        $captcha=$_POST['g-recaptcha-response'];

    if(!$captcha){
        echo '<h2>Please check the the captcha form.</h2>';
        exit;
    }

    $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR SECRET KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
    if($response['success'] == false)
    {
        echo '<h2>You are spammer ! Get the @$%K out</h2>';
    }
    else
    {
        echo '<h2>Thanks for posting comment.</h2>';
    }
?>

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
recaptch validation in php how to validate recaptcha in PHP recaptcha v2 validation php recaptcha v3 validation php recaptcha validation in php how to validate recaptcha php recaptcha php validation google recaptcha v2 php example recaptcha v2 php validation google recaptcha in php google recaptcha verify response php php code for google captcha verification google captcha v2 php example recapthca php function verify google recptcha php how to add 2capatcha to a website in php how to implement recaptcha with php how to make google recaptcha appear after filling email address how to display google recaptcha after entering the details in form google captcha php code google captcha syntax Captcha in php google php recaptcha howto userecaptchain php how to add recaptcha to php add captcha php how to add google recaptcha in php adding recaptcha 3 to your site php adding recaptcha3 to your site php adding recaptcha to your site php how to use google captcha in php how to use google captcha in pho google recaptcha v2 validation php add google recpatcha v2 in php form google recaptcha in php form how to add recaptcha php google captcha example in php add recaptacha in html php php make recaptcha php add captcha google recaptcha php recaptcha php form recaptcha php integration step by step php how to add reCaptcha captcha server side validation in php code how to embed google recaptcha secret key in php mail how to use recaptcha in php simple recaptcha php google captcha php php google recaptcha recaptcha php login add google captcha php php captcha google php code to implement google captcha Simple Recapcha PHP google captcha v2 php add recaptcha to php form most basic number adding reCaptcha php how to implement google re captcha in php form recaptcha php code recaptcha implementation php recaptcha php how to add recaptcha in php implement google recaptcha PHP php form reCAPTCHA how to setup recapthca for php how to add recaptcha validation in php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source