Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6210889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:14:27+00:00 2026-05-24T06:14:27+00:00

am trying to validate recaptcha with ajax, the only problem am facing is that

  • 0

am trying to validate recaptcha with ajax, the only problem am facing is that it always sais that recapthca was typed wrong!even when i did it right!
i really wonder what is wrong with my code!

<?php
    require_once('recaptcha/recaptchalib.php');
    define("PUBLICKEY"," ");
    define("PRIVATEKEY"," ");

    $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    if ($resp->is_valid) {
    ?>success<?
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $reason = $_POST['reason'];
        $header = 'From: ' . $email . " \r\n";
        $msg = "Sent from: " . $name . "\r\n";
        $msg .= "Email: " . $email . " \r\n";
        $msg .= "Phone: " . $phone . " \r\n";
        $msg .= "Contact reason:" . $reason . " \r\n";
        $msg .= "Message: " . $_POST['message'] . " \r\n";
        $msg .= "Date and time " . date('d/m/Y', time());

        $to = '';
        $subject = 'contact page';

        mail($to, $subject, utf8_decode($msg), $header);
    }
    else 
    {
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
       "(reCAPTCHA said: " . $resp->error . ")");
    }
?>

on the form page i have this

<?php 
    require_once('recaptcha/recaptchalib.php');
    define("PUBLICKEY","");
    define("PRIVATEKEY"," ");
?>

<div id="contact-form">
<?php echo  $content; ?>
        <form action="#" method="POST" id="contactForm" onSubmit="return validateCaptcha()">
    <div class="form">
            <label for="name">Your Name: <span class="requireds">(Required)</span><br /></label>
            <input id="name" name="name" class="text-input" minlength="2" />
   </div>
   <div class="form">
            <label for="email">Your Email:<span class="requireds">(Required)</span><br /></label>
            <input id="email" name="email" class=" text-input" />
   </div>
   <div class="form">
            <label for="phone">Your Phone:<br /></label>
            <input id="phone" name="phone" type="text"  maxlength="200" class="text-input"  />
   </div>
   <div class="form">
            <label  for="reason">Contact reason:<br /></label>
            <select id="reason" name="reason" class="select">
                <option>Sales question </option>
                <option>Time/ Delivery</option>
                <option>My existing Order</option>
                <option>Technical Question</option>
                <option>Revision/ Support</option>
                <option>Other</option>

            </select>
   </div>
   <div class="form">
            <label for="message">Message: <span class="requireds">(Required)</span> <br /></label>
             <textarea id="message" name="message" class="textarea"></textarea>
   </div>

   <div style="margin:10px 0; width:495px;  -moz-border-radius:3px; border-radius:3px;">
                <p style="color: #f14444; text-align:right; font-size:12px" id="captchaStatus">&nbsp;</p>
                    <?php echo recaptcha_get_html(PUBLICKEY); ?>

      </div>
       <input type="submit"  value="" class="send"/>

    </form> 

i already checked if the public and private key are correct..
does somebody have an idea about what is wrong on this code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:14:28+00:00Added an answer on May 24, 2026 at 6:14 am

    You are receiving this error when submitting the recaptcha which tells me that your API key is not being submitted properly:

    To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create

    Update:

    recaptcha_check_answer ($privatekey,

    See the problem there? You’re using $privatekey instead of PRIVATEKEY so you’re actually submitting nothing as your private key. The error was correct (trust the error messages!). I use Chrome’s built in developer tools (Ctrl+Shift+i) to debug this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate an input field by making sure that only text, spaces
I am trying to validate inputs that can be altered by users in one
I'm trying to validate items inside a treeview. The main idea is that a
im trying to validate a string of text that must be in the following
I'm trying to validate that a submitted URL doesn't already exist in the database.
I'm trying to validate a drivers license for a form that i am making.
I'm trying to validate a user's windows credentials on a computer that's not joined
I'm trying validate an X.509 certificate received over a network. I have understood that
I am trying to validate textfield for numbers only. I am using the following
I'm trying to validate a textarea making sure that each line starts with 'http://':

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.