Jump to content

problems with recaptha field in form


webguync

Recommended Posts

I have a form which is working, but the client wanted to add a recapatcha field so I am implementing that and placed the recaptcha code in the same directory as my form. The recaptcha displays, but you can enter in anything and the form still submits, so it's not doing any good!

 

Not sure where the problem lies exactly, but was hoping for some help if someone has experienced anything similar.

 

here is my code

 

in the html

<li>
<pre> <script> var RecaptchaOptions = {

  theme : 'clean'

}; </script> </pre>
<?php
          require_once('../ContactUs/recaptchalib.php');
          $publickey = "6LdZX8ASAAAAABUejj-bfZey47TTjN6X-EKfKBwy "; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>


                 </li>

 

the PHP to submit the Post data

<?php

if(!$_POST) exit;

$email = $_POST['email'];

if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{

$values = array ('name','email','phone','concerning','message','recaptcha_response_field');
$required = array('name','email','message','recaptcha_response_field');

$your_email = "email@email.com";
$email_subject = "New Message from our web site!";
$email_content = "new message:\n";

foreach($values as $value){
  if(in_array($value,$required)){
    if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
    $email_content .= $value.': '.$_POST[$value]."\n";
  }
}

if(mail($your_email,$email_subject,$email_content)) {
echo 'Your message has been successfully sent!'; 
} else {
echo 'ERROR! please try again or use the email address listed above to contact Sandbox-Band';
}
}
?>


 

the recaptchalib.php file is exactly as I downloaded it from their site.

Link to comment
Share on other sites

ReCaptcha may be different than the Captcha script I've been using... but I dont see any code in your PHP script to check a value... it appears that you're only checking to see if they filled in a value.

 

This may help: http://code.google.com/apis/recaptcha/docs/verify.html

 

And This: http://code.google.com/apis/recaptcha/docs/php.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.