How to Add Recaptcha in your Website [php]

How to add ReCaptcha? this is not so difficult for you when you read this article. You can add ReCaptcha in any form, word press, php, HTML, JavaScript, page. Now the first Question is:


Why we use recaptcha?

Sometimes when you make submit the form on your website for the e.g-Contact page, signup page etc.. Then you get a lot of people sign up or contact you by name like this asfdsgas, sdgsfd, fhgfdre . This is nothing but someone spam your website.So do not worry ! by ReCaptcha you can stop this.Now

Where I can use ReCaptcha?

You can use reCAPTCHA in your HTML page, PHP page, page even in your WordPress, Joomla, sites. I show you how to use in all platform.

  • Add reCAPTCHA in HTML,PHP page form    

    1. Make a simple form
      <form name=”ajax-form” id=”ajax-form” action=”” method=”post”>
      <input name=”name” id=”name” type=”text” placeholder=”Full Name” />
      <input name=”email” id=”email” type=”text” placeholder=”E-mail” />
      <input name=”contact” type=”text” placeholder=”Contact No.” />
      <textarea name=”comment” id=”message” placeholder=”Write your Comment”></textarea><input class=”send_message” id=”send” type=”submit” /></form>
    2. Now add this before submit button (do not forget to put public key ?)
      <?php  require_once(‘recaptchalib.php);
      $publickey= “”;
      echo recaptcha_get_html($publickey);
    3. Put this link in your contact information submission page.
      $privatekey = “”;
      $resp = recaptcha_check_answer ($privatekey,
      $_POST[“recaptcha_response_field“]);if (!$resp->is_valid) {
      // What happens when the CAPTCHA was entered incorrectly
      die (“The reCAPTCHA wasn’t entered correctly. Go back and try it again.” .
      “(reCAPTCHA said: ” . $resp->error . “)”);
      } else {      //————- HERE IS YOUR CONTACT INFO SUBMISSION CODE    }  ?>
    4. Now all are done test it.
  • Add reCAPTCHA in ASP.Net Page 

  1. Make form in page
  2. Before form insert this code
    <%@ Register TagPrefix=“recaptcha” Namespace=“Recaptcha” Assembly=“Recaptcha” %>
  3. In form insert this code
  4. Now your final code look like this
    <%@ Page Language=“VB” %>
    <%@ Register TagPrefix=“recaptcha” Namespace=“Recaptcha” Assembly=“Recaptcha” %>
    <script runat=server%gt;
    Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
    If Page.IsValid Then
    lblResult.Text = “You Got It!”
    lblResult.ForeColor = Drawing.Color.Green
    lblResult.Text = “Incorrect”
    lblResult.ForeColor = Drawing.Color.Red
    End If
    End Sub
    <form runat=“server”>
    <asp:Label Visible=false ID=“lblResult” runat=“server” />
    <asp:Button ID=“btnSubmit” runat=“server” Text=“Submit” OnClick=btnSubmit_Click />


I hope you got it !. I suggest you to every time you make a form or any submission/upload path to your website server you must insert reCAPTCHA in your page.


Leave a Reply

Your email address will not be published. Required fields are marked *