We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47666
    • 43 Posts
    I'm starting to think maybe it might be easier while I'm still learning modX to try what sottwell mentioned earlier…

    Quote from: sottwell at Jun 25, 2014, 11:14 PM
    MODX sets its own session, with its own storage and its own session_name. If you are setting a session variable in a script outside of MODX, you have to use the same session. The best thing would be to load a MODX object and let MODX open a session. http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/loading-modx-externally

    If anyone understands this can you please help with the syntax and explain where I put it? If I keep all the php files in the script folder in the main directory. How would I save a session variable in scripts/process-step1.php

    If anyone has seen a tutorial or some document ion that explains this in a simple manner please let me know. I looked at this but it didn't make sence to me on how to do what I'm trying to do.

    http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/loading-modx-externally

    Thanks again everyone for all their help.
      • 39404
      • 175 Posts
      stalemate resolution associate Reply #32, 12 years, 3 months ago
      You could also create a snippet called getSessionID and in it put this:

      <?php
      $sessionId = session_id();
      if(!isset($sessionId)) {
          session_start();
      }
      define('SESSION_ID',session_id());
      echo SESSION_ID;
      ?>
      


      Please take the others' advice over mine but if you can't their ideas to work, try this.

      Regards,
      Tom
        • 47666
        • 43 Posts
        So I stripped out pretty much everything and I'm just trying to get a really form manually without formIt.

        Here is my form:
        <form class="form-inline home1"  id="home1" role="form" action="[[++site_url]][[~17]]" method="POST">
        
                    <div id="input-wrap" class="">
                    
                      <div class="form-group ">
                        <label class="sr-only" for="">Zip Code</label>
                        <input type="text" class="form-control" placeholder="Zip Code" name="zip" id="zip" style="max-width: 120px;">
                      </div>
                        
                      <div class="form-group pull-right" >
                        <label class="col-lg-3 sr-only control-label">Products</label> 
                        <select class="form-control" name="product" style="width:140px;">
                          <option value="" selected>Product</option>
                          <option value="Auto">Auto</option>
                          <option value="Boat">Boat</option>
                          <option value="Commercial">Commercial</option>
                          <option value="Commercial Property">Commercial Property</option>
                          <option value="Condo">Condo</option>
                          <option value="Homeowners">Homeowners</option>
                          <option value="Life">Life</option>
                          <option value="Motorcycle">Motorcycle</option>
                          <option value="Renters">Renters</option>
                          <option value="Workers Compensation">Workers Compensation</option>
                        </select>
                      </div>
                    
                    </div><!-- close input wrap -->
                                  
                    <button id="next1" class="btn btn-orange btn-block" type="submit" >Get Started</button>
                   
                  </form>
        


        I created a new resource named processForm with an id of 17. In the content section (with Toggle Editor unchecked) I placed the following code to reference my php snippet:
        [[11]]
        


        Finally I have a Snippet, process-step1, with an id of 11 and the following code.

        <?php
        
        $var = "Hello World";
        return $var;
        
        // if(isset($_POST['zip'])){
        // 	$zip = mr_clean($_POST['zip']);
        // 	return $zip;
        
        // }
        // else{
        //     echo "no post";
        // }
        


        Since I couldn't even get this to work, I commented out the post variables and I'm just trying to print "Hello World" to the screen by returning var.

        What am I doing wrong???
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          Instead of [[11]] use [[nameOfSnippet]] - snippet tags (all tags, really) refer to the name and not the ID of the element being requested. [ed. note: markh last edited this post 12 years, 3 months ago.]
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 3749
            • 24,544 Posts
            Quote from: markh at Jul 01, 2014, 08:55 AM
            Instead of [[11]] use [[nameOfSnippet]] - snippet tags (all tags, really) refer to the name and not the ID of the element being requested.

            Except link tags. wink
              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
              • 47666
              • 43 Posts
              thanks guys. That fixed it!!! The session variables and everything.