Web Analytics Made Easy -
StatCounter Move recaptcha validation - CodingForum

Announcement

Collapse
No announcement yet.

Move recaptcha validation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Move recaptcha validation

    I use recaptcha on my site but for some reason when i test my form if i leave it blank it doesnt spit back any error, and also i cant get it to validate before my form is checked.

    This is the whole code for it which is currently in the middle of my form
    PHP Code:
    //blahblah rest of the form up here
    Enter Validation Code:<br /><br>
    <?php
            
    require('recaptchalib.php');


            
    // Get a key from https://www.google.com/recaptcha/admin/create
            
    $publickey "6LfKI8cSAAAAAHEAK9vir063pXncb72-kw_DVj3L";
            
    $privatekey "6LfKI8cSAAAAAFOpgdi29sxTlhIck7t2ufB3YWOW";
            
            
    # the response from reCAPTCHA
            
    $resp null;
            
    # the error code from reCAPTCHA, if any
            
    $error null;

            
    # was there a reCAPTCHA response?
            
    if ($_POST["recaptcha_response_field"]) 
            {
                
    $resp recaptcha_check_answer ($privatekey,
                                                
    $_SERVER["REMOTE_ADDR"],
                                                
    $_POST["recaptcha_challenge_field"],
                                                
    $_POST["recaptcha_response_field"]);
                if (
    $resp->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);
    ?>
    //last of the form and submit button down here
    I want to move the checking part to the beginning of my form so if there are any errors i can display before my form loads but i cant get it to work if i move anything, can anyone else?
Working...
X