We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36631
    • 10 Posts
    Hello,
    i try to use $_Post within a REVO snippet.

    $email = $_POST['email'];

    Unfortunately $email is allways empty. Is there a trick how to read $_Post values in Modx?

    Thanks, Phil
      • 3749
      • 24,544 Posts
      That should work fine as long as the value has been set in a form and the form has been submitted with

      method="post".
      [ed. note: BobRay last edited this post 15 years, 1 month 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
        • 36631
        • 10 Posts
        Hi Bob,

        i doesn't work for me. Here is what i do:

        From my content for the page newsletter.php i call a snippet:
        <?php
        $email='';
        $email = $_POST['email'];
        echo $email;

        and a chunk:
        <form id="kontaktformular1" method="post" action="newsletter.php">
        <label for="email">Ihre E-Mailadresse:</label><input type="text" size="30" maxlength="128" id="email" name="email" />
        <input type="submit" id="submit1" value="Send"/>
        </form>


        When i fill the emailadress in the form and send it, i come back to the same page (which is good), but nothing is echoed. (And yes, i know one shouldn't use echo - but it neither works with if ($email){do something})

        Any ideas?

        Thx, Phil
          • 3749
          • 24,544 Posts
          The problem may be with your action. Assuming that the form is posting to itself, try changing it to:

          action="[[~[[*id]]]]"


          If it's posting to another page, make it:

          action="[[~##]]"


          where ## is the ID of the page it's posting to.
            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