We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31902
    • 342 Posts
    I was wondering if anyone out there successfully integrated reCatcha on a form that was running through Form Tools ( http://www.formtools.org ) on a MODx site.

    I've successfully integrated Form Tools many times with MODx and it works great but this is the first time I've tried adding reCaptcha.

    The problem is that, as part of the install, I'm required to add this to the top of the page:

    <?php
    require_once("../form/global/api/api.php");
    ft_api_start_sessions();
    $fields = isset($_SESSION["form_tools_form_data"]) ? 
      ft_strip_tags($_SESSION["form_tools_form_data"]) : array();


    ...which I've done through a snippet. Unfortunately, when I do, I get an error message that reads:

    Warning: require_once(../path/to/formtools/global/api/api.php) [function.require-once]: failed to open stream: No such file or directory in /home/example/domains/example.com/public_html/core/cache/includes/elements/modsnippet/31.include.cache.php on line 7
    
    Fatal error: require_once() [function.require]: Failed opening required '../formtools/global/api/api.php' (include_path='.:/usr/local/lib/php') in /home/example/domains/example.com/public_html/core/cache/includes/elements/modsnippet/31.include.cache.php on line 7


    That api,php file, by the way, is on the server.

    Not sure if it matters, it happens whether the site is running with user friendly URLs or not.

    I tried emptying site cache (deleting contents of core/cache) and made sure it is writable.

    Not that it matters, but I tried just adding the reCaptcha call (through a snippet) just before the submit button, which looks like this:

    <?php
    ft_api_display_captcha();


    and it results in this error message:

    Fatal error: Call to undefined function ft_api_display_captcha() in /home/example/domains/example.com/public_html/core/cache/includes/elements/modsnippet/32.include.cache.php on line 7


    I tried adding another snippet to the page...one that I had made...just to see if it was a problem with the page handling snippets, but it ran okay. It seems to be something with the reCaptcha code.

    Yes, I've tried looking through the Form Tools forums, etc but I didn't find anything useful. I think I need an answer that is more MODx specific.

    Thank you in advance.

    MODx 2.2.1
    PHP Version 5.2.10
    [ed. note: waizen last edited this post 14 years, 5 months ago.]
      • 3749
      • 24,544 Posts
      You could use the full path to the file rather than a relative path. That will load the file, but I'm not sure the session() stuff won't interfere with MODX session handling.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 31902
        • 342 Posts
        Thanks, Bob. Yeah, I tried the full path thing and it didn't work. Hmmm... maybe the session handling thing is getting in the way.

        Any other way to handle reCaptcha that anyone knows of?
          • 3749
          • 24,544 Posts
          FormIt uses reCaptcha. If FormIt doesn't do what you want, its code might give you some ideas.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 31902
            • 342 Posts
            Thanks. I'll see if the boss wants me to go ahead and redo the forms on the site for FormIt. [ed. note: waizen last edited this post 14 years, 5 months ago.]
              • 31902
              • 342 Posts
              || Epilogue ||


              I ended up redoing the form in FormIt, which worked great. The only thing missing with FormIt is an easy way (easy for me, anyway) to have the data sent to and saved to a database, with a way to manage it from the control panel. That's the benefit that Form Tools brings to the mix. Form Tools uses its own control panel (not directly through MODx) but it's a small price to pay.

              Oh, well, maybe in Revo v 5.0.0 some day. [ed. note: waizen last edited this post 14 years, 5 months ago.]
                • 3749
                • 24,544 Posts
                With FormIt, you have to either use a postHook to write to the DB, or use Bruno17's formit2db snippet: https://forums.modx.com/thread/?thread=32560&page=1


                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 31902
                  • 342 Posts
                  Yeah, I've been all over that tutorial but I have to admit that that's where my talents are somewhat limited. It seems to involve the db stuff on a server level (including the management of data) and that is a bit beyond me at this time. Still learning every day, though I admit to being more of an implementer of these things, rather than straight-up coder. Wish one of the MODx rockstars (maybe you, Bob, as if you're not busy enough?) could come up with some back-end solution of some sort (think: Gallery or Quip component) to serve as a control area for something like that.

                  Or, maybe I'm just making that tutorial out to be a lot harder than it actually is?

                  The great thing about Form Tools (did I plug that system enough?) is that the client can use the system's control panel to manage the data. That includes editing it, downloading it to csv or excel spread sheet, edit/compose the outgoing emails and more. Very easy to do and the client can do it.