We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40649
    • 40 Posts
    Hi All,

    I posted this in the "formit" discussion two days ago on this forum and did not get a response... can someone here help? smiley

    I've attached my code to this post for review... I have the latest version of formit, and would like my contact form to redirect to a "thank you" page, require the name, phone, comment/question, and validate all of that (and the recaptcha) prior to sending an email. I have setup the public/private keys in the system settings and put the following code in my contact page. Right now, the form is not redirecting to the "thank you" page, not requiring the fields I'd like, just refreshing the contact form page/recaptcha on submit. Can someone look at my code/correct it so it will do the things I mentioned in the first sentence of this post?
      • 3749
      • 24,544 Posts
      I don't see anything obvious that's wrong.

      If you just want a quick, simple contact form, you could try SPForm which requires very little configuration in Revolution. It will use the MODX Captcha extra rather than reCaptcha, but no keys are required.


      ------------------------------------------------------------------------------------------
      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
        • 40777
        • 6 Posts
        Are there any more forms on the page? If so, try using the submitVar property for the formit snippet.

        Otherwise, does it work if you skip the recaptcha / spam hook?

        Anything in the modx error log?
          Web developer at http://kaigan.se
          • 40649
          • 40 Posts
          Hi- I tried switching to the SPF form, but didn't have any luck and wanted a little more control over it. I removed the recaptcha/spam hook and don't have anything in the modx error log. Specifically, here are my issues:

          1. The contact page is not redirecting to the "thank you" page... or id=2... on submit.

          2. The form is not sending the email to the [email protected] address.

          My code for all three places (snippet, resource, chunk) is below. Please let me know what errors you see and how I can correct this. Thanks for your help-- I'm super new to Modx! smiley

          This is my snippet:
          /**
           * FormIt
           *
           * Copyright 2009-2012 by Shaun McCormick <[email protected]>
           *
           * FormIt is free software; you can redistribute it and/or modify it
           * under the terms of the GNU General Public License as published by the Free
           * Software Foundation; either version 2 of the License, or (at your option) any
           * later version.
           *
           * FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
           * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
           * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
           *
           * You should have received a copy of the GNU General Public License along with
           * FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
           * Suite 330, Boston, MA 02111-1307 USA
           *
           * @package formit
           */
          /**
           * FormIt
           *
           * A dynamic form processing Snippet for MODx Revolution.
           *
           * @package formit
           */
          require_once $modx->getOption('formit.core_path',null,$modx->getOption('core_path',null,MODX_CORE_PATH).'components/formit/').'model/formit/formit.class.php';
          $fi = new FormIt($modx,$scriptProperties);
          $fi->initialize($modx->context->get('key'));
          $fi->loadRequest();
          
          $fields = $fi->request->prepare();
          return $fi->request->handle($fields);
          
          [[!FormIt
             &hooks=`email,redirect`
             &emailTpl=`MyEmailChunk`
             &emailSubject=`High Priority: Contact Form Submission from AmmoniaGauges.com`
             &emailTo=`[email protected]`
             &redirectTo=`2`
             &validate=`name:required,
                email:required,
                phone:required,
                subject:required,
                text:required:stripTags` 
          ]]


          This is my resource page for the "contact us":
          <div id="skip">
          <a href="#side-content">Go to Navigation</a>
          <a href="#main-content">Go to Content</a></div>
          
          
          <div id="header" class="clear">
           <p id="logo"><a href="/" title="De Mar & Associates. Providing High quality products since 1953">De Mar & Associates. Providing High quality products since 1953</a></p>
           <p id="slogan">Family Owned & Operated. Call Us at 913.381.6810</p>
          </div>
          
          <div id="body" class="clear">
          <!-- End Head -->
          <div id="main-content">
          
           </br>
          
          
          [[!FormIt
             &hooks=`email,redirect`
             &emailTpl=`MyEmailChunk`
             &emailSubject=`High Priority: Contact Form Submission from AmmoniaGauges.com`
             &emailTo=`[email protected]`
             &redirectTo=`2`
             &validate=`name:required,
                email:required,
                phone:required,
                text:required:stripTags` 
          ]]
          
          <h1>Contact Us Today!</h1>
           </br>
          [[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
           
          <form action="[[~[[*id]]]]" method="post" class="form">
              <input type="hidden" name="nospam:blank" value="" />
           
              <label for="name">
                  Name: <input type="text" name="name" id="name" value="[[!+fi.name]]" />
          
                  <span class="error">[[!+fi.error.name]]</span>
              </label>
              
          </br>
          <label for="phone">
                  Phone:
          <input type="text" name="phone" id="phone" value="[[!+fi.phone]]" />
                  <span class="error">[[!+fi.error.phone]]</span>
              </label>
              
          </br>
           
              <label for="email">
                  Email:
          <input type="text" name="email" id="email" value="[[!+fi.email]]" />
                  <span class="error">[[!+fi.error.email]]</span>
              </label>
             
           </br>
             
              <label for="text">
                  Questions/Comments: </br>  <textarea name="text" id="text" cols="55" rows="7" value="[[!+fi.text]]">[[!+fi.text]]</textarea>
                  <span class="error">[[!+fi.error.text]]</span>
              </label>
           
              
              <div class="form-buttons">
                  <input type="submit" value="Send Inquiry" />
              </div>
          
          
          </form>
          
          
          </div>
          
          <div id="side-content">
           <ul id="main-navigation">
           <li><a href="[[~25]]" rel="nofollow">Home</a></li>
           <li><a href="[[~10]]">About Us</a></li>
           <li><a href="[[~12]]">Gauge Standard Features</a></li>
           <li><a href="[[~22]]"> 8.5" Installations</a></li>
           <li><a href="[[~6]]">Utility Grade Installations</a></li>
           <li><a href="[[~7]]">Agricultural Installations</a></li>
           <li><a href="[[~17]]">Panel Installations</a></li>
           <li><a href="[[~3]]">Custom Gauge Designs</a></li>
           <li><a href="[[~15]]" rel="nofollow">Contact Us</a></li>
          </ul>
          <div>
          <a href="[[~15]]" rel="nofollow"><img class="image" src="/assets/images/cta-02.jpg" alt="Receive 10-15% discount off your first order" title="You Will Receive 10-15% Off Your First Order" /></a>
          </div>
          <address>
          <p>De-Mar & Associates<br />
          4490 Indian Creek Parkway<br />
          Overland Park, KS 66207</p>
          
          <p>Phone: 913.381.6810<br />
          Fax: 913.381.9332<br />
          Hours: 8:30am - 5pm CST</p>
          <p><img src="/assets/images/overland-park.jpg" id="overland" alt="Overland Park Chamber of Commerce" /></p>
          </address>
          </div>
          
          <div id="affiliates">
          	<h3>Our Groups & Associations</h3>
          	<div id="logo-block">
          	<ul class="clear">
          	 <li><a href="http://www.NFIB.com" id="nfib" title="NFIB (National Federation of Independent Business) " rel="nofollow">nfib</a></li>
          	 <li><a href="http://www.MANAonline.org" id="mana" title="Manufacturers' Agents National Association">mana</a></li>
          	 <li><a href="http://www.ymcarockies.org" id="ymca" title="YMCA of the Rockies" rel="nofollow">ymca</a></li>
          	 <li><a href="http://www.jamidamerica.org" id="junior-achv" title="Junior Achievement of Middle America, Inc." rel="nofollow">junior-achv</a></li>
          	 <li><a href="http://www.bmtinfonet.org" id="bmt" title="Blood and Marrow Transplant Information Network" rel="nofollow">bmt</a></li>
          	</ul>
          	<ul class="clear">
          	 <li><a href="http://www.stjude.org" id="st-jude" title="St. Judes Childrens Hospital" rel="nofollow">st-jude</a></li>
          	 <li><a href="http://www.4spe.org" id="spe" title="SPE (Society of Plastics Engineers) ">spe</a></li>
          	 <li><a href="http://www.childrensmercy.org" id="chldrn-mrcy" title="Children's Mercy" rel="nofollow">chldrn-mrcy</a></li>
          	 <li><a href="http://www.kcashrae.org" id="shraea" title="ASHRAE - Kansas City Chapter " rel="nofollow">shraea</a></li>
          	 <li><a href="http://www.unmc.edu" id="nmc" title="University of Nebraska Medical Center " rel="nofollow">nmc</a></li>
          	 </ul>
          	 </div>
          </div></div>
          <div id="footer">
          <p>Copyright © 2007 De-Mar & Associates - Ammonia Gauges, All Rights Reserved <a href="/sitemap.html">Sitemap</a></p>
          </div>
          
          <script type="text/javascript">
          var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
          document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
          </script>
          <script type="text/javascript">
          var pageTracker = _gat._getTracker("UA-1952959-1");
          pageTracker._initData();
          pageTracker._trackPageview();
          </script>


          This is my email chunk:
          This is the Formit Email Chunk.
           
          <br />[[+name]] ([[+email]]) Wrote: <br />
           
          [[+text]]
          :
            • 32316
            • 387 Posts
            Does your snippet really have a FormIt call in it?

            The call is the code that starts [[!FormIt [ed. note: whistlemaker last edited this post 14 years, 2 months ago.]
              • 3749
              • 24,544 Posts
              Try installing the QuickEmail extra to make sure your email is working at all. In FormIt, if the email hook fails, the redirect hook will not execute.



              ------------------------------------------------------------------------------------------
              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
                • 40649
                • 40 Posts
                Hi Bob Ray,

                QuickEmail sends the email, which I set up to go to a gmail account because I'm testing to see if the issue is with the server email I had before. However, I am still not getting an email and the page is not redirecting when I submit. Thoughts on what to try next? Thanks for your help! smiley
                  • 3749
                  • 24,544 Posts
                  Are you using the same domain and email addresses (to, from, replyto) used by QuickEmail (it will show them if you set $debug=`1`)? Some servers are very picky about those, especially if you're testing on a localhost install.

                  Sometimes it helps to switch to an SMTP account using the MODX STMP System Settings.


                  ------------------------------------------------------------------------------------------
                  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
                    • 40649
                    • 40 Posts
                    The Quickemail sent to the client's email- which is not a gmail account, but an ISP account. I switched the SMTP account setting to "yes." I am sick to my stomach over this and feel like I have no way to get it resolved because I have so little knowledge of what the issue is. I've been searching the forum for hours-- please send any and all suggestions. smiley
                      • 3749
                      • 24,544 Posts
                      In order to use SMTP, you'd need to set all the SMTP settings correctly. If QuickEmail sends without SMTP, you should probably just turn SMTP back off.

                      I looked over your code again and I finally spotted one critical error: You need a question mark after the snippet name.

                      [[!FormIt?


                      Here's a page that would have helped (see #2): http://bobsguides.com/insidious-modx-errors.html

                      Don't feel like it's just you, we all hate debugging email problems and have spent many hours tearing our hair out over them and I think we've all made the missing question mark error. wink




                      ------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using.
                      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 2 months ago.]
                        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