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'm pretty sure Bruno17's code is in a snippet in MODX just like yours.

    What do you see if you do a "View Source" on the form page?


    BTW, you should be able to use this for the action since you want to post to the current page:


    <form name="form" action="[[~[[*id]]]]" method="get">


    Also, you should really do it this way (or use a Tpl chunk):

    $output = '';
    $output .= "\n" . '<form name="form" action="[[~[[*id]]]]" method="get">';
    $output .= "\n    " . 'Name: <input type="text" name="name" value="John Doe"><br>';
    $output .= "\n    " . 'E-mail: <input type="text" name="email" value="[email protected]"><br>';
    $output .= "\n    " . '<input type="submit">';
    $output .= "\n" . '</form>';
    $output .= "\n" . $_GET["name"];
    $output .= "\n" .  . '<br />';
    $output .= "\n" . $_GET["email"];
    
    return $output;
      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
      • 4172
      • 5,888 Posts
      Quote from: BobRay at Nov 28, 2013, 09:52 PM
      I'm pretty sure Bruno17's code is in a snippet in MODX just like yours.

      I have copy/pasted exactly strooman's code into a snippet.

      For some Testing try this:

      snippet 'makeUrl':
      $docId = $modx->resource->get('id'));
      return $modx->makeUrl($docId);


      and this on your page:

      current Resource-id: [[*id]]<br />
      generated by makeUrl: [[!makeUrl]]<br />
      generated by tag: [[~[[*id]]]]<br />


      [ed. note: Bruno17 last edited this post 12 years, 10 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44891
        • 35 Posts
        Quote from: BobRay at Nov 28, 2013, 09:52 PM


        What do you see if you do a "View Source" on the form page?
        I see this:

        <html>
        <head>
        <title>MODX Revolution - test</title>
        <base href="http://bertverberne.com/" />
        </head>
        <body>
        <form name="form" action="http://bertverberne.com/index.php?id=2" method="get">
        Name: <input type="text" name="name" value="John Doe"><br>
        E-mail: <input type="text" name="email" value="[email protected]"><br>
        <input type="submit"></form><br />
        </body>
        </html>
        



        Quote from: Bruno17 at Nov 28, 2013, 11:15 PM
        Quote from: BobRay at Nov 28, 2013, 09:52 PM
        I'm pretty sure Bruno17's code is in a snippet in MODX just like yours.

        I have copy/pasted exactly strooman's code into a snippet.

        Then why returns your example a page with html extension? I thought Modx returns pages with php extension.

        Quote from: Bruno17 at Nov 28, 2013, 11:15 PM
        For some Testing try this:


        snippet 'makeUrl':
        $docId = $modx->resource->get('id'));
        return $modx->makeUrl($docId);
        current Resource-id: [[*id]]

        generated by makeUrl: [[!makeUrl]]

        generated by tag: [[~[[*id]]]]
        That gives me the right parameters however the final result is still that I don't land on the right page e.g. wrong redirect. Sorry I repeat myself! It would be easier if you experiment with the code yourself and expirience the given problem which is always a kick back to the home page. It's not that I have a very big problem here because I can work around it (see reply #15). It now became more of a mystery because the code doesn't do what it supposed to do.
          • 44891
          • 35 Posts
          Tackeld it with just plain and simple php code! Just the way I was looking for.

          Snippet code:
          <?php
          if(isset($_POST['submit'])) 
          { 
          $name = $_POST['name'];
          $email = $_POST['email'];
          echo 'You entered this name : <b>' . $name . '</b><br />';
          echo 'You entered this email : <b>' . $email . '</b>';
          }
           
          echo '<form method="post" action="index.php?id=4">';
          echo 'Name: <input type="text" name="name" value="John Doe"><br>';
          echo 'E-mail: <input type="text" name="email" value="[email protected]"><br>';
          echo '<input type="submit" name="submit" value="Submit Form"><br>';
          echo '</form>';
          ?>


          In any page:
          [[!snippetname]]

          Form action part -> "index.php?id=4" -> change whatever you like and it wil land there.
          Changed form method from get to post.
            • 3749
            • 24,544 Posts
            Apparently the $_GET params were messing up the URL for some reason. I'm glad you got it sorted. I suspect that your original code would have worked with $_POST.
              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
              • 4172
              • 5,888 Posts
              Quote from: strooman at Nov 29, 2013, 10:48 AM

              Then why returns your example a page with html extension? I thought Modx returns pages with php extension.

              FURLs on?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!