We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I’ve been wrestling with this for a couple of days and am hoping these symptoms mean something to the MODx geniuses here.

    I’ve got a simple form in a snippet that posts to itself with:

    $output .= '<form action="'.'http://mydomain.com/'.'[~[*id*]~]' .'" method="post">';


    When I click on "submit", rather than showing the form again, it goes to the site’s home page.

    Strangely, the line in the browser window shows the correct address (the form page).
    Even stranger, if I put the cursor in the address box and press enter, I get the form again (but with nothing posted to it).

    If, instead, I hit refresh, I see the "repost" warning box, so I know the POST data is there but it goes to the home page again.

    I have friendly URLS and friendly aliases on.

    The site is in a subdirectory (actually a sub-account).

    I can reach all the pages fine through the Wayfinder menu so I know the FURLs are working.

    I did have the form snippet working fine at one point (I think with friendly aliases off and hardcoding the form action) so I know the snippet is ok and the POST data is present.

    I have separate pages for "page not found" and "unauthorized page" -- both published and reachable from the Wayfinder menu and set in config -- but the form post never goes to them and there are no errors in the error log.

    When I look at the source of the form page, the form action line looks as it should, with the correct URL of the form as the action.

    Bob, baffled

    UPDATE: Problem turned out to be a missing </form> tag in the snippet. Strangely, it didn’t cause a problem using the MODx default minimal template. It only went south when I switched to my own template. As always, WC3 validation is your friend!


      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
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Have you tried it with
      $output .= '<form action="[~[*id*]~]" method="post">';

      I would imagine that your "404" page is the home page. You could also check your apache error logs to find out what’s going on there.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 3749
        • 24,544 Posts
        Quote from: sottwell at Oct 08, 2007, 11:24 AM

        Have you tried it with
        $output .= '<form action="[~[*id*]~]" method="post">';

        I would imagine that your "404" page is the home page. You could also check your apache error logs to find out what’s going on there.

        Susan,

        I tried your code and get the same result except that putting the cursor in the browser’s addresss window and pressing enter now leads to the "repost" warning instead of going straight to the page. It still goes to the home page when "submitted" and still shows the correct URL (the form page) in the address window.

        As I mentioned in my post, the 404 page is not set to the home page in Tools | Config and there are no errors reported in the Apache log. Also, that wouldn’t explain how the URL is correct in the address window. That’s why I’m so baffled.

        The only thing I can remember doing that could have affected things was to change the template for all pages (using Doc Manager -- Thank you). I’ve cleared the site cache and the browser cache repeatedly with no luck.

        Bob
          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
          • 33372
          • 1,611 Posts
          It sounds to me as if your subdomain redirect is the problem. You might have a conflict between your FURLs setup and your subdomain redirect (the order of those rewrite rules matters). Does it work with FURLs off?
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 3749
            • 24,544 Posts
            Quote from: ZAP at Oct 08, 2007, 12:30 PM

            It sounds to me as if your subdomain redirect is the problem. You might have a conflict between your FURLs setup and your subdomain redirect (the order of those rewrite rules matters). Does it work with FURLs off?

            Unfortunately, no.

            I see this in the address window after submitting the form (3 is the id of the form page), but it still shows the home page below.

            http://mydomain.com/index.php?id=3

            And it still goes to the form page if I put the cursor in the address window and hit enter.

            I’m out of stuff to try.

            Bob
              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
              • 3749
              • 24,544 Posts
              Update:

              I switched back to the minimal template and the form is working (with or without FURLS and/or friendly aliases).

              Obviously, something is wrong with my template. I haven’t figured out what (base href is the same for both templates), but at least I know where to look now.

              Bob
                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
                • 3749
                • 24,544 Posts
                Quote from: BobRay at Oct 08, 2007, 05:56 PM

                Update:

                I switched back to the minimal template and the form is working (with or without FURLS and/or friendly aliases).

                Bob

                I solved it and it’s still pretty weird. The problem was in the snippet code. The <form> tag had no closing </form> tag. (When will I learn to do W3C validation a little sooner when I encounter weirdness? embarrassed ).

                The strange thing is that it caused no problem using the MODx default minimal template. It only showed up when I used my own template.

                Bob
                  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