We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12379
    • 460 Posts
    no programming skills here, so I need to be gently walked through setting up sessions please in modx to store values from a multipage form, for example:

    <!--checkout-step-1.html-->
    <form name="theform" action="checkout-step-2.html" method="POST" onsubmit="return CheckForm(this)">
    First name: <input name="b_first" type="text" value="[[b_first]]" size="20" />
    Last name: <\<input name="b_last" type="text" value="[[b_last]]" size="20" />
    <input type=submit value="Next" class="cformbutton" />

    <!--checkout-step-2.html-->
    <form name="theform" action="checkout-step-3.html" method="POST" onsubmit="return CheckForm(this)">
    Address:<input name="d_addr" type="text" value="[[d_addr]]" size="34" />
    City: <input name="d_city" type="text" value="[[d_city]]" size="21" />
    <input type=submit value="Next" class="cformbutton" />


    The user may need to move back and forward between pages altering info too, hence the value="[[snippet]]". The last page has a summary of all the information for reviewing. I have a lot a values for processing on each page too. I know there’s a solution with eform, however it’s not suitable to use with my shopping cart and checkout processing.
      Mostly harmless.
      • 12379
      • 460 Posts
      Thanks but can anyone help out here please? Have set up 3 test templates each with their own session [[snippet]] at the very top. The first two form pages collect some values and the third provides a summary. I’ve used the exact code ganehsXL suggested for the snippets. First two pages appear to work, but with the 3rd page I get the error below with no values passed to its form fields.

      Parse error: syntax error, unexpected T_VARIABLE in /home/xxxx/public_html/modx/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 2


      [[snippet]] at top of p1 & 2:
      <?php
      $_SESSION['formval1'] = trim($_POST['formval1']);
      $_SESSION['formval2'] = trim($_POST['formval2']);
      etc
      etc
      ?>


      [[snippet]] at to of page 3:
      <?php
      $modx->setPlaceholder('formval1' $_SESSION['formval1']);
      $modx->setPlaceholder('formval2' $_SESSION['formval2']);
      $modx->setPlaceholder('formval3' $_SESSION['formval3']);
      $modx->setPlaceholder('formval4' $_SESSION['formval4']);
      etc
      etc
      ?>
        Mostly harmless.
        • 12379
        • 460 Posts
        Thanks! The error has disappeared now. Still no values passed to page 3 however. Have double checked the code.

        Here’s the input tag for the initial input of data which I assume is correct.

        <input name="formval1" type="text" value="" size="34" />
          Mostly harmless.