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

    I need to create a multi-page form - a sort of wizard that sends variables from one page to the next in order to accumulate some variables for calculations on final completion of the form and also to let the next page know which section to show. This is not to send an email but simply to perform some calculations, show sections of form content depending on variables, etc. Hope that is clear enough....

    Can anyone guide me as to how on earth this is done - I am a bit stuck on this and assistance would be very much appreciated.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You can use the $_SESSION to carry the values from page to page; that is what sessions are for, after all.
        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
        • 28224
        • 17 Posts
        Yes, I could use sessions to hold the variables. However, I am using php to take the variables and decide in the page which parts of the form to show on the next page. I am doing this within a snippet as I am under the impression that php should be used within snippets and using echo ’ some text ’; to try and output to the page, but even a simple echo statement is not resulting in the form html being output to the page and I simply get a blank page.
          • 26435
          • 1,193 Posts

          <?php
          $page = $_POST[’page’];

          switch ($page)
          {
          case ’page1’:
          return ’Form Output’;
          break;

          case ’page2’:
          return ’Form for page 2’;
          break;

          default:
          return ’Initial Form’;
          break;
          }
          ?>

          -sD-
          Dr. Scotty Delicious, DFPA.
            Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
            All of the above... in no specific order.


            I send pointless little messages
            • 7455
            • 2,204 Posts
            you could use this snippets I made to put all fields in a session and one snippet that creates placeholders from the sessions that can be used on the next page (or any page)

            http://modxcms.com/forums/index.php/topic,15350.0.html

            greets Dimmy
              follow me on twitter: @dimmy01
              • 3749
              • 24,544 Posts
              Quote from: spooky at Dec 09, 2007, 04:33 AM

              ...even a simple echo statement is not resulting in the form html being output to the page and I simply get a blank page.

              A blank page often means an error in your php code (or in the html it produces).
              Just leaving off a ";" character from the end of a line of php code or having an odd number of quotation marks or parentheses will often confuse the php parser enough that it may just give up and produce an empty page.

              Feel free to post your code here if you can’t fix it yourself.

              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
                • 28224
                • 17 Posts
                Thanks all.

                Bob, you were spot on. Ported this wizard from asp to php and some text had ’ in the words, which was not escaped, thus the php code was failing. First time using php, so I will cut myself some slack on that... Having sorted that nonsense out everything is fine and works as I would expect it to work.

                Off topic, but after using Drupal and hand-coding other sites, I am very impressed with modx. Templating is a breeze, integrated SMF and using it’s user-handling, generated code seems reasonably clean - love it. grin
                  • 7231
                  • 4,205 Posts
                  Spooky; you are in luck...first php, then MODx, your life has just gotten easier. grin I used to code in asp and the minute I discovered php I never looked back.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]