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

    Quick question. When I include a form in my modX site and post to an alias name, the post data does not seem to make it to the page.

    eg:

    <form name="form" action="confirm.html" method="post">

    On the confirm.html page I have then written a snippet to take the post data and do something. However when I post to the above (confirm.html) there is nothing in any of the post variables?

    I have found 2 workarounds, if I use the get method the data is in the querystring, but this is not ideal. Also if I post using the id of the page I can access the posted data fine in the snippet????

    eg:

    <form name="form" action="index.php?id=23" method="post"> (WORKS FINE FOR ME)

    Is there some strange re-direct going on when the alias is posted to? Anyone come across this before? I would very much like to post to the alias rather than index.php?id=xyz!!!

    Cheers,

    Justin.







      • 25663 MODX Staff
      • 12,272 Posts
      Goofy question, but is the form page cached?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 15083
        • 697 Posts
        hi there rthrash,

        Both pages, ie the form and the reciveing page are both set to NOT cache.
        the reason the form is set NOT to cache is due to the fact that it is dynamically generated based on where the user has come from.

        Have I done something silly?? smiley

        Cheers,

        Justin.
          • 25663 MODX Staff
          • 12,272 Posts
          No that’s the right way to set it up. Now I’ll let those that might actually be able to figure out what’s going on there step in. wink
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 32241
            • 1,495 Posts
            Try this one.

            Set base href on your template, located inside your header tag. Set the value to point to your domain root of your MODx installation.

            Use [~doc_num~] as the action. Don’t forget to replace doc_num into your document id where you want your form to post back.
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 15083
              • 697 Posts
              hi Djamoer,

              thanks for the help, unfortunatly it is still not posting data.
              I added the modX root to the base href of the template.

              I then posted to:

              <form name="form" action="[~21~]" method="post"> (21 being the id of the page to accept the form post)

              However on page 21 I have a snippet to boot the user back to booking.html if n post data is found. This is happening every time. Again if I post to <form name="form" action="index.php?id=21" method="post"> it works a treat!!! Strange. I have also noticed that if I click back to the page above I get a warning about the page needing post data, this does not seem to happen if I navigate between alias names???? Does this help??

              Cheers and thank you!!

              Justin.
                • 32241
                • 1,495 Posts
                Can you post a code that you use for redirection?
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                  • 15083
                  • 697 Posts
                  Hi there,

                  Sorry for the delay...busy weekend!!!

                  The code I use to re-direct is as follows:

                  if (isset($_POST[’discount_Code’])) {

                  //Do something in here....but I never get here posting to xyz.html, only when I post to index.php?id=21

                  } else {

                  $modx->sendRedirect("booking.html");

                  }

                  So all I can conclude is that the posted data does not make it??

                  Cheers,

                  Justin.
                    • 25663 MODX Staff
                    • 12,272 Posts
                    I believe that there are fixes in the imminent 0.9.2 to the redirect code.
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 15083
                      • 697 Posts
                      Hi rthrash...

                      redirection code aside, I think this problem is still there. If I remove the re-direction code and just test if the page has received a post, it has not when I post to the alias name, and has when I post to the script name ie index.php?id=blah

                      Well its no biggie, I have found a workaround, however as stated above there are issues when you click back from a form post direct to the script name.....you get that annoying warning page.