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

    im really sorry to jump in on this thread again but ive been really trying and still cannot seem to get this working?
    im new to php, trying to learn my way through it but dont know enough to know why this isnt working, every change ive tried has failed.
    i tried to do exactly as you said Breezer
    adding
    <?php
    $data=$_POST['data'];
    $output ='';
    if(!$data){
      $output .='<form method="post" action="[~192~]" id="Form">
      <input type="text" name="data" id="data" />
      <input type="submit" value="Submit" />
      </form>';
    }else{
    // Set placeholders:
       $DataArray = array(
                    'data'    => $data
                    );
    // Return the chunk
      $output .= $modx->parseChunk('PostDataTestChunk', $DataArray, '[+', '+]');
    }
    
    unset($data);
    return $output;
    ?>

    to a snippet called "showData"

    which should pass the data array to a chunk called /* this snippet would call a chunk named "PostDataTestChunk"
    which contains

    <p>Data: [+data+]</p>



    so that my page with [!showData!] gets redirected to a page that has{PostDataTestChunk} but still the value for my form field data remains blank

    im not sure what to do/try next?

      • 3749
      • 24,544 Posts
      Is 192 the id of the page with the form snippet on it? It should be, since the example assumes that the form posts to itself rather than redirecting to another page.
        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