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

    Try as I might I cannot get FormIt to redirect to my Thank You page.
    I have tried everything suggested (well, obviously not everything yet).

    My emails send successfully.
    The acknowledgements arrive safely too.
    The Resource (17) exists and is published.

    However after 'SEND' is clicked I get

    'NOT FOUND'
    The requested URL /index.php was not found on this server.


    Strangely, if I turn FURL's off, things seem to work correctly.
    Can anyone see my deliberate mistake here?


    my FormIt call...

    [[!FormIt?
       &hooks=`spam,email,math,redirect,FormItAutoResponder`
       &emailUseFieldForSubject=`1`
       &emailTpl=`sentEmailTpl`
       &emailTo=`[email protected]`
       &emailSubject=`enquiry`
       &spamEmailFields=`email`
       &fiarTpl=`emailAutoResponse`
       &fiarFromName=`[[++emailsender]]`
       &fiarSubject=`Enquiry`
       &customValidators=`firstname,surname,email,text,math`
       &validate=`lastname:blank,
                  firstname:required,
                  surname:required,
                  email:email:required,
                  text:required:stripTags,
                  math:required`
       &redirectTo=`17`
    ]]


    And my contact form...

    [[!+fi.validation_error_message:notempty=`<p class="error">[[!+fi.validation_error_message]]</p>`]]
    
    <form action="[[~[[*id]]]]" role="form" method="post">
        
        <p>* all fields required please</p>
        
        <input type="hidden" name="lastname" value=""><!--bot killer-->
        <div>    
            <label>name</label> 
                [[!+fi.error.firstname:notempty=`<span class="error">[[!+error.firstname]]</span>`]]
    
            <input type="text" name="firstname" id="firstname" aria-label="Enter your first name" value="[[!+fi.firstname]]" />
        </div>
        <div>
            <label>surname</label>
                [[!+fi.error.surname:notempty=`<span class="error">[[!+error.surname]]</span>`]]
    
            <input type="text" name="surname" id="surname" aria-label="Enter your surname" value="[[!+fi.surname]]" />
        </div> 
        
        <div>
            <label>email</label>
                [[!+fi.error.email:notempty=`<span class="error">[[!+error.email]]</span>`]]
    
            <input type="text" name="email" id="email" aria-label="Enter your email address" value="[[!+fi.email]]" />
        </div>
    
        <div>
            <label>enquiry</label>
                [[!+fi.error.text:notempty=`<span class="error">[[!+error.text]]</span>`]]
                <textarea type="text" name="text" id="text" aria-label="Enter your enquiry" value="[[!+fi.text]]"></textarea>
        </div>
           
        <div class="maths-bot-killer">
            <label>Not a robot?</label>
            <p>Ok then, what is</p>
            <p><strong>[[!+fi.op1]] [[!+fi.operator:is=`-`:then=`minus`:else=`plus`]] [[!+fi.op2]]?</strong></p>
        </div>
            
        [[!+fi.error.math]]
        <input type="text" name="math" aria-label="Enter the answer to the sum" value="[[!+fi.math]]" placeholder="Answer"/>
        <input type="hidden" name="op1" value="[[!+fi.op1]]" />
        <input type="hidden" name="op2" value="[[!+fi.op2]]" />
        <input type="hidden" name="operator" value="[[!+fi.operator]]" />
        
        <button type="submit">SEND</button>
        <button type="reset" value="RESET">reset</button>
    
    </form>
    



    My setup:
    MODX latest (2.5.2)
    MAMP (latest (3.0.7.3))
    PHP (5.5.26)
    MySQL (5.5.38)
    Chrome: Std and Canary (latest versions allowable by OS)
    Mac OX (Mountain Lion-10.8.5).

    I need a fresh pair of eyes here
    Thank you guys [ed. note: geordiechris last edited this post 7 years, 4 months ago.]
      • 3749
      • 24,544 Posts
      Is the email hook successful? If not, the redirect hook won't execute.

      You might try moving the math hook ahead of the email hook. If that doesn't work, try moving it ahead of the spam hook.
        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
        • 50272
        • 89 Posts
        Hi Bob

        Well, I got it to work in the end.
        Though not sure how. I ended up backtracking and pretty much starting afresh to be honest.

        I got the original built-in hooks ordering to work i.e.
        &hooks=`spam,email,math,redirect,FormItAutoResponder`


        That said, with reference to ordering, aside 'spam' preceding 'email' being a must do
        (as I understand it), I'm curious as to how 'math' ahead of 'email', for example, would work,
        logistically that is…


        Anyway, thanks once again for your time
          • 3749
          • 24,544 Posts
          I'm glad you got it sorted. smiley

          As you probably guessed, the hooks execute in the order they are listed. You want spam ahead of email because you want the spam check to be carried out before the email is sent, not after. wink
            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
            • 50272
            • 89 Posts
            Yes I did kinda fathom (after a fashion) that the hooks executed in order,
            and that 'spam' before 'email', for example, makes very good sense…
            as does, with reference to a form filling sequence, 'redirect' followed by 'FormItAutoResponder' (though that, I guess, could be reversed).
            However, your suggestion of 'math' ahead of 'email' and/or 'spam'
            seems out of kilter with that principle.
            Is 'math' a special case then?
            To be clear, this only comes from a place of curiosity,
            and not one of smart assery!

            Thanks again
            [ed. note: geordiechris last edited this post 7 years, 4 months ago.]
              • 3749
              • 24,544 Posts
              Good point. I was thinking that the math hook was involved in displaying the math string, but on second thought, it can't be.

              It should probably be right before or after the spam hook, but it has to be ahead of the email hook if you don't want emails to be sent when the math test fails.
                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
                • 50272
                • 89 Posts
                All noted Bob

                Much appreciated
                  • 50272
                  • 89 Posts
                  Sorry guys,
                  spoke too soon.

                  It appeared to work well until I hardened the site up by placing the core outside the public_html.
                  I've setup and re-setup and checked and triple checked.
                  This has worked for me in the recent past...
                  https://www.sepiariver.ca/blog/modx-web/benefits-of-the-modx-advanced-installation/
                  I follow it to the letter, but it seems something is awry.

                  The emails successfully send.
                  I don't get any 404's, just an indication of an error appearing over the contact form.
                  All the fields contents are still in place except the main text message field which is empty.

                  My Formit call which works before moving the core is this…

                  [[!FormIt?
                     &hooks=`math,spam,email,FormItAutoResponder,redirect`
                     &emailUseFieldForSubject=`1`
                     &emailTpl=`sentEmailTpl`
                     &emailTo=`[email protected]`
                     &emailSubject=`enquiry`
                     &spamEmailFields=`email`
                     &fiarTpl=`emailAutoResponse`
                     &fiarFromName=`[[++emailsender]]`
                     &fiarSubject=`Website enquiry`
                     &customValidators=`firstname,surname,email,text,math`
                     &validate=`lastname:blank,
                                firstname:required,
                                surname:required,
                                email:email:required,
                                text:required:stripTags,
                                math:required`
                     &redirectTo=`17`
                  ]]


                  I've tried all permutations of &hooks.
                  Resource 17 exists and is published
                  Plus lots of other suggestions

                  This is driving me to distraction!

                  Any further ideas guys?
                  Pleeeease!!

                  Believe me, this is appreciated
                    • 3749
                    • 24,544 Posts
                    I can't think of any way that moving the core would affect this process other than a cache issue.

                    I assume that you've tried manually deleting all the core/cache files and using private or incognito mode in your browser.
                      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
                      • 50272
                      • 89 Posts
                      Absolutely Bob…constantly.
                      I hit upon a thread that talked about the link_tag_scheme having a bearing on things.
                      I tried the 'abs' setting which seemed to do the trick.
                      Though this proved to be a stab in the dark, as it worked once only.
                      As I say the emails were arriving fine and I was even getting the acknowledgements through without a problem.
                      It was just the redirection to the Thank you page that was not working.

                      However it seems now more to do with the SMTP settings…
                      After a couple (or six) of fresh installs and migrations I have it working ok now (everything crossed).
                      I've looked through all the System and resource settings and nothing seems out of the ordinary.

                      Not that much the wiser to be honest, but I have it working nicely.
                      Maybe as there are so many steps involved I was going wrong somewhere.
                      One thought was I use Susan Ottwell's 'install.php'.
                      However I hadn't twigged that I wasn't using the latest update of that (install.php)
                      and so found myself installing MODX 2.51 remotely and then having to install the updateModx extra
                      to update to 2.52 to match the local site setup, before exporting (via vapor) its (the local site) contents to the remote site.
                      IYO might that have had a bearing perhaps?

                      I will also use the incognito mode…hadn't given that a thought to be frank.

                      So many thanks
                      Much appreciated