Page 1 of 19 12311 ... LastLast
Results 1 to 10 of 188
  1. #1
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    help question Adding reCAPTCHA to Contact Us Form

    Hello,

    I was wondering if someone could tell me what files I need to edit in order to add reCAPTCHA to my 'Contact Us' form. I did a search for contact us in the developer's toolkit and was unsuccessful in finding the necessary files.

    ReCAPTCHA requires modifications to the actual form as well as to the file that actually processes the form. According to reCAPTCHA's instructions, these are two separate files but I can't find them.

    Thanks for your help.

  2. #2
    Join Date
    Jul 2006
    Location
    Montreal, Canada
    Posts
    2,279
    Plugin Contributions
    0

    Default Re: Adding reCAPTCHA to Contact Us Form

    i don't know about reCaptcha but , in free add on , you have few captcha modules that will do that for you .

  3. #3
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    help question Re: Adding reCAPTCHA to Contact Us Form

    OK. I figured out how to get the actual reCAPTCHA module inserted into the contact us form, but now I'm having trouble figuring out where to insert the code that actually checks to make sure the value entered is what is displayed in the captcha.

    Here's the code that needs to be entered:

    Code:
    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) {
      die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
           "(reCAPTCHA said: " . $resp->error . ")");
    }
    As things are now, a customer can fill out the form and skip the captcha and the form will still be sent. How do I make the form "realize" that the captcha needs to be filled out properly?

    Thanks,

  4. #4
    Join Date
    Dec 2007
    Location
    Payson, AZ
    Posts
    1,076
    Plugin Contributions
    15

    Default Re: Adding reCAPTCHA to Contact Us Form

    includes\modules\pages\contact_us\header_php.php

    Should be able to place it near the top under this line..

    Code:
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    I use recaptcha on another site, but I still like ttf captcha better for my zen.
    Dave
    Always forward thinking... Lost my mind!

  5. #5
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    help question Re: Adding reCAPTCHA to Contact Us Form

    I entered the code as mentioned above, but now whenever I click on the link to my contact form a blank page appears that says telling me I haven't entered the captcha information correctly.

    Here's the code as I currently have it:

    Code:
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    require_once('includes/templates/custom/templates/recaptchalib.php');
    $privatekey = "****************";
    $resp = recaptcha_check_answer ($privatekey,
        $_SERVER["REMOTE_ADDR"],
        $_POST["recaptcha_challenge_field"],
        $_POST["recaptcha_response_field"]);
    
    if (!$resp->is_valid) {
      die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
           "(reCAPTCHA said: " . $resp->error . ")");
    }
    
    $error = false;
    if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
      $name = zen_db_prepare_input($_POST['contactname']);
      $email_address = zen_db_prepare_input($_POST['email']);
      $enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));
    The code in red is the actual verification code for the captcha. The rest I included so you could see where in the header_php.php file I put it.

    Any suggestions?
    Last edited by Ajeh; 13 Apr 2009 at 06:11 AM.

  6. #6
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    help question Re: Adding reCAPTCHA to Contact Us Form

    I got this mostly working right now. Thanks everybody for your suggestions.

    This has led to another problem which I'll post a separate thread on.

  7. #7
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    help question Where is the contact us form success action being called from? (ReCAPTCHA)

    Hello,

    I recently added ReCAPTCHA to my website and am having a problem. If the user forgets to validate the captcha on the contact form, they are sent to a blank page that displays an error and asks them to go back and try again. However, using the browser's back button just causes a message about needing to resend the data to come up, keeping the user in an endless loop where they can't get back to the form. I want to modify the page that comes up when the form is filled out successfully so that if the customer forgets to validate the captcha they are presented with an error message and a back button to go back to the form. If they fill out the form properly, then the normal success message is displayed.

    Now my question: where in the code for the contact us form is the success action defined and called up? I'm assuming it's an action because the address for the success page is http://www.basphoto.com/index.php?ma...action=success.

    Also, how would I modify the "Back" button so it takes users back to the form instead of to the homepage?

    Thanks,

  8. #8
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    Default Re: Where is the contact us form success action being called from? (ReCAPTCHA)

    Quote Originally Posted by bsteinagel View Post
    Hello,

    I recently added ReCAPTCHA to my website and am having a problem. If the user forgets to validate the captcha on the contact form, they are sent to a blank page that displays an error and asks them to go back and try again. However, using the browser's back button just causes a message about needing to resend the data to come up, keeping the user in an endless loop where they can't get back to the form. I want to modify the page that comes up when the form is filled out successfully so that if the customer forgets to validate the captcha they are presented with an error message and a back button to go back to the form. If they fill out the form properly, then the normal success message is displayed.

    Now my question: where in the code for the contact us form is the success action defined and called up? I'm assuming it's an action because the address for the success page is http://www.basphoto.com/index.php?ma...action=success.

    Also, how would I modify the "Back" button so it takes users back to the form instead of to the homepage?

    Thanks,
    Update: The customer can enter go back to the form using the back button properly now. I don't know why I was having problems before but I'm not having problems with that particular issue now. I'm still looking for help on the other problems though.

  9. #9
    Join Date
    Sep 2007
    Location
    Neenah, WI
    Posts
    112
    Plugin Contributions
    0

    Default Re: Where is the contact us form success action being called from? (ReCAPTCHA)

    By "other problems" I meant the problems with modifying the form success page to display the error. Sorry for any confusion.

  10. #10
    Join Date
    Dec 2007
    Location
    Payson, AZ
    Posts
    1,076
    Plugin Contributions
    15

    Default Re: Adding reCAPTCHA to Contact Us Form

    Lost me with your other messages, but getting back to your first request.... This is what worked for my testing...

    for includes\modules\pages\contact_us\header_php.php

    add this just below the $error = false;

    Code:
     require_once('includes/templates/custom/templates/recaptchalib.php');
    $privatekey = "PRIVATE-KEY-GOES-HERE";  
    $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
    
    if ($_POST['submitted'] == 'yes' && !$resp->is_valid) {
        $error = true;
        
    }
    then go down to this line... and add the red section.
    Code:
     if ($zc_validate_email and !empty($enquiry) and !empty($name) and $resp->is_valid) {
    now for includes\templates\classic\templates\tpl_contact_us_default.php

    bottom of the page above the submit button code you see a </fieldset> just above it paste this code..
    Code:
    <?php
         if ($error == true) {
            echo '<span style="color:red;font-style:bold;">*Please re-try entering the 2 word reCAPTCHA:</span>';
        }
        //require_once('recaptcha/recaptchalib.php');
        $publickey = "PUBLIC-KEY-GOES-HERE";  
        echo recaptcha_get_html($publickey);
    ?>
    Of course replace the KEY-GOES-HERE with your key.

    This work for my tests, if captcha fails, your back to the contact us page. If all is right your on to the success page.
    Dave
    Always forward thinking... Lost my mind!

 

 
Page 1 of 19 12311 ... LastLast

Similar Threads

  1. Contact reCAPTCHA
    By nolsowski in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 29 Apr 2012, 08:54 PM
  2. Contact Recaptcha
    By Miff in forum General Questions
    Replies: 1
    Last Post: 15 Jun 2011, 10:40 PM
  3. Adding a contact form
    By Matt Smith in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 8 Jun 2010, 11:27 PM
  4. Using two modules add extra fields and recaptcha to contact form
    By webmiss in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 22 Feb 2010, 07:43 PM
  5. Removing default contact info on contact us page/adding form to page
    By haggis0929 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 28 Dec 2009, 06:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR