Form Help

TOPIC:

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

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10064
  • Karma: 167
  • Thanks: 808
Hi,

like this:
echo    '<script type="text/javascript">
                    alert("Captcha failed, please try again!");
                    history.go(-1);
                </script>';

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

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

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

TheMuffinMan wrote: Hi,

like this:

echo    '<script type="text/javascript">
                    alert("Captcha failed, please try again!");
                    history.go(-1);
                </script>';


Not really liking the User experience on that one.
I guess there's no other cleaner method to do this.

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

Re: Recaptcha in Classic Form? 9 years 2 weeks ago #70516

  • psrch's Avatar
  • psrch
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 27
  • Thanks: 0
I'm working on this myself, but I've run into a bit of a snag. Here's what I have:

Three fields - name, email, message (I'm not using an upload for this one).

Action script for submit button - ff_validate_submit

Before Form Piece:
echo '<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>';

After Form Piece:
echo '<script type="text/javascript">
           Recaptcha.create("XXxxxxxxXxXXX", "recaptcha_div", {                   // public key
             theme: "blackglass",
             callback: Recaptcha.focus_response_field});
      </script>';

Begin Submit Piece:
$this->execPieceByName('ff_InitLib');
$recipient = 'foo@test.com'; // Change to your admin Email address
$subject="Test reCaptcha";

require_once('administrator/components/com_breezingforms/libraries/recaptcha/recaptchalib.php');
$privatekey = "XXxxxxxxXxXXX";

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) {
        // Create email
           $body =
                'Message sent from SiteOne Development website' . "\r\n"."\r\n"."\r\n" .
                ff_getSubmit('message');

           $attachment = NULL;
           $html = NULL;
           $bcc = NULL;
           $cc = NULL;
           $reply = NULL;

        // send the email 
           $this->sendMail(
           ff_getSubmit('email'),
           ff_getSubmit('name'),
           $recipient,
           $subject
           $body,
           $attachment,
           $html,
           $cc,
           $bcc,
           $reply
           );
    }
    else {
echo    '<script type="text/javascript">
                    alert("Captcha failed, please try again!");
                    history.go(-1);
            </script>';
        exit;
    }
}

End Submit Piece:
$this->execPieceByName('ff_InitLib');
header('location: /thanks.html');
exit;


Here's what's happening:
If I don't enter the captcha text or any other information, I'm redirected to the thank you page. No email is sent
If I enter everything EXCEPT the recaptcha, I'm redirected to the thank you page. No email is sent.
If I enter everything - text and recaptcha - I'm directed to the thank you page, and no email is sent.

What am I missing?

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

Re: Recaptcha in Classic Form? 9 years 2 weeks ago #70612

  • Topic Author
  • Ingrid
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
The error message must be here.

echo {
and there what happens when code was entered correctly.

regards

Ingrid

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

Re: Recaptcha in Classic Form? 9 years 2 weeks ago #70620

  • psrch's Avatar
  • psrch
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 27
  • Thanks: 0
Yes, that's what I have. If you look at what I have in the Before Submit piece, you wil see:

if ($resp->is_valid) {
        // Create email
           $body =
                'Message sent from SiteOne Development website' . "\r\n"."\r\n"."\r\n" .
                ff_getSubmit('message');

           $attachment = NULL;
           $html = NULL;
           $bcc = NULL;
           $cc = NULL;
           $reply = NULL;

        // send the email 
           $this->sendMail(
           ff_getSubmit('email'),
           ff_getSubmit('name'),
           $recipient,
           $subject
           $body,
           $attachment,
           $html,
           $cc,
           $bcc,
           $reply
           );
    }
    else {
echo    '<script type="text/javascript">
                    alert("Captcha failed, please try again!");
                    history.go(-1);
            </script>';
        exit;
    }

which is the same thing, except I'm using an "if true" condition instead of "if not true"

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

Last edit: Post by psrch.
Moderators: ForumSupport
Time to create page: 0.042 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!