I am using reCaptcha and for some odd reason, I keep getting this error:

is_valid) { echo "You got it!"; } else { # set the error code so that we can display it $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); ?>

Can someone explain to me what is wrong?

Recommended Answers

All 2 Replies

Member Avatar for LastMitch

@<MICHAEL>

is_valid) { echo "You got it!"; } else { # set the error code so that we can display it $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); ?>

Can you post the code that comes with that error. It's a bit hard to see the error without a code.

Did you include the javascript in the file?

Since you are using reCAPTCHA. Have you should read this:

https://developers.google.com/recaptcha/docs/php

I've read that link before...

Here is my code:

   <?php
  require_once('recaptchalib.php');
  $privatekey = "";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    echo "Sorry, your inquiry failed to submit. Please revise your inquiry and resubmit.";
  } else {
    echo"Thank you, your inquiry has been recieved! We will review it and get back to you as soon as possible!";
  }
  ?>
  <html>
  <script type="text/javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
</script>
    <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers -->
      <!-- your HTML content -->
      <input name="name" type="text" id="name" onBlur="MM_validateForm('name','','R','email','','RisEmail','subject','','R','message','','R');return document.MM_returnValue" size="55" placeholder="Name"><br>  
<input name="email" type="text" id="email" size="55" placeholder="Email"><br>  
<input name="subject" type="text" id="subject" size="55" placeholder="Phone"><br>  
<label>Message</label><br>  
<textarea name="message" id="message" rows="4" cols="40"></textarea><br>
    <form action="" method="post">


      <form method="post" action="recaptcha.php">
        <?php
          require_once('recaptchalib.php');
          $publickey = ""; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>
        <input type="submit" name="submit1" value="Submit" />
      </form>

      <!-- more of your HTML content -->
    </body>
  </html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.