Form Help

TOPIC:

Re: Recaptcha in Classic Form? 9 years 2 months ago #66469

  • Topic Author
  • Ingrid
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Hello,

This code works in my form:
  require_once('administrator/components/com_breezingforms/libraries/recaptcha/recaptchalib.php');
  $privatekey = "your private key";
  $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
  die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");

  } else {
            
           header('location: /danke');
           exit;
              
}

"die" gives a new page which is displayed oustside of joomla. And I can't find out the solution...
I want to stay on the side with the form, and the error should also be shown here.

Please Log in or Create an account to join the conversation.

Re: Recaptcha in Classic Form? 9 years 2 months ago #66479

  • Topic Author
  • Ingrid
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
I got it.
  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
           header('location: /error-captcha');
           die ();

  } else {
            
           header('location: /danke');
           exit;
              
}

An in the side of the error captcha this <a href="javascript:history.back()">zurück</a>. Loaded over loadposition with a custom modul.

Hope it helps.

Please Log in or Create an account to join the conversation.

Re: Recaptcha in Classic Form? 9 years 2 months ago #66507

  • Topic Author
  • Ingrid
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
mailback to sender is without verifying, and email is sent twice to the sender.
First by verifying and second after verifying is correctly.

Please Log in or Create an account to join the conversation.

Re: Recaptcha in Classic Form? 9 years 2 months ago #66598

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10064
  • Karma: 167
  • Thanks: 808
does it work now? If yes, I would propose if you could export the form and donate it to the users in the form apps section? Thanks!

Please Log in or Create an account to join the conversation.

Re: Recaptcha in Classic Form? 9 years 2 months ago #66599

  • jpresult
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 49
  • Thanks: 0
Hi,

I think the captcha is working. But it's not working completely.
I tried the following code, and there are 3 different cases.
1. when I fill in the correct captcha it goes to a page and echo's out the alert "OK".
2. when I fill in an incorrect captcha it goes to a page and echo's out the alert "Error".
3. when I don't fill in the captcha, it reloads the page and sends the email. It shouldn't send an email in this case.

This made me realize that I need to have some validation for the recaptcha if it's empty. But it's static text. So how do I add validation here?
require_once('administrator/components/com_breezingforms/libraries/recaptcha/recaptchalib.php');
$privatekey = "XXxxxXXXXXxxxxXxxXx";

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 '<script type="text/javascript">
                  //location.go(-1);
                  alert("Error");
              </script>';
        exit;
    }
    else
    {
    echo '<script type="text/javascript">
                  alert("OK");
              </script>';
        exit;
    }
}

EDIT: Turns out that when you fill in a wrong captcha it reloads the page and sends the email. This also shouldn't happen. So in all cases the email is beign sent.

Please Log in or Create an account to join the conversation.

Last edit: Post by jpresult.

Re: Recaptcha in Classic Form? 9 years 2 months ago #66600

  • jpresult
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 49
  • Thanks: 0

TheMuffinMan wrote: does it work now? If yes, I would propose if you could export the form and donate it to the users in the form apps section? Thanks!


I will definitely share it, as soon as it's working properly

Can you take a look at my previous post? Seems like I'm missing something to prevent the email from beign sent.

Please Log in or Create an account to join the conversation.

Last edit: Post by jpresult.
Moderators: ForumSupport
Time to create page: 0.044 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!