Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    reCaptcha working correcting.

    Hey guys, having slight troubles getting my ReCaptcha to work. I have a form that the user must fill out correctly before it sends me an email and loads up a new page, If I blank out my ReCaptcha code everything works how I want - but I need the reCaptcha on my form I can't figure out how to get my work where it loads the message after my submit button all it does is refresh.. here's the code, not sure if its all the you guys need to figure it out. Will be happy to send full code if needed. (sorry I'm kind of new)

    Code:
    <!--ReCAPTCHA -->
    <?php require_once('recaptchalib.php');
      $publickey = "6LcKbeUSAAAAAPebMsf38ZsbLs1pkkj-W6JRoxaS"; // you got this from the signup page
      echo recaptcha_get_html($publickey);
      ?>
      <?php
      
      if (isset($_POST['submit'])){
    
      require_once('recaptchalib.php');
      $privatekey = "6LcKbeUSAAAAABoenA5RB81vs59VIWIQvkU41vHE";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
    
      if (!$resp->is_valid) {
        // What happens when the CAPTCHA was entered incorrectly
      }
    }
       ?>
      <!--Error Checking -->
    
    
    </div><!-- end .input -->
    </div><!-- end .row -->
    <!-- submit button -->
    <div class="submit">
      <input name="submit" id="submit" type="submit" value="Submit" />
    <?php else: ?>
    <p style="font-size:35px; font-family:Arial, Helvetica, sans-serif; color:#255E67; text-align:center;">Thank you for your Message!</p>

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,993
    Thanks
    15
    Thanked 233 Times in 233 Posts
    PHP Code:
    if (!$resp->is_valid) {
        
    // What happens when the CAPTCHA was entered incorrectly
     
    }
    else {
    // What happens when it was successful.};
     
    }
       
    ?> 
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #3
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DrDOS View Post
    PHP Code:
    if (!$resp->is_valid) {
        
    // What happens when the CAPTCHA was entered incorrectly
     
    }
    else {
    // What happens when it was successful.};
     
    }
       
    ?> 
    That brings up an error with the PHP help line:

    PHP Code:
    <?php else: ?>

  • #4
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by arghyajit View Post
    if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    }
    else {// What happens when it was successful.};
    }
    ?>
    how's that any different from what DrDOS said?

  • #5
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    here's the full code on the page if it helps:

    http://pastebin.com/2pS1LgRg

  • #6
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,993
    Thanks
    15
    Thanked 233 Times in 233 Posts
    if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    }
    else {
    // What happens when it was successful.
    }
    ?>
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #7
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am so confused? This is correct?? Why do I get this error?


  • #8
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    If you don't have an "if" that matches with the else on 225, then it'll give you an error. If there is no matching if, remove it. Based on its location, seems like code is missing. For example, a submit div opens, but doesn't close?

  • #9
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok, I've changed around to this and it works how I want it ... however it still wont load the page after i click submit (div class="submit").

    PHP Code:
    <?php
      
      
    if (isset($_POST['submit'])){

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

      
        
    // What happens when the CAPTCHA was entered incorrectly
    if (!$resp->is_valid) {
        
        echo 
    $error_messages['reCAPTCHA'];
    }
      }
    ?>
      <!--Error Checking -->


    </div><!-- end .input -->
    </div><!-- end .row -->
    <!-- submist button -->
    <div class="submit">
      <input name="submit" id="submit" type="submit" value="Submit" />
    <?php else: ?>
    <p style="font-size:35px; font-family:Arial, Helvetica, sans-serif; color:#255E67; text-align:center;">Thank you for your Message!</p>



    <script type="text/javascript">
    setTimeout('ourRedirect()', 5000)
    function ourRedirect(){
        location.href='contact.php'
    }


    </script>

    <script language="javascript">

    var time_left = 5;
    var cinterval;

    function time_dec(){
      time_left--;
      document.getElementById('countdown').innerHTML = time_left;
      if(time_left == 0){
        clearInterval(cinterval);
      }
    }

    cinterval = setInterval('time_dec()', 1000);

    </script>

    <p style="font-size:20px; font-family:Arial, Helvetica, sans-serif; color:#000; font-weight:bold; text-align:center;13px;">Redirecting In <span id="countdown">5</span>.</p>

    <?php endif; ?>
    If I don't have the recaptha code everything works fine and how I want it. if i click submit it brings up a page and directs you back to the form while sending me an email with the data... how do I make it do the same with having the ReCAPTCHA - all it does with the ReCAPTCHA is load the form page again??

    I know this is hard to understand im sorry :\

  • #10
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    anyone please? :\


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •