We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32365
    • 42 Posts
    I’m new to both php so let me know if this is a dumb question or not, but is it possible for a php form to record what user(while they’re logged in of course) submitted some information and then use that recorded user information to show extra options/content on a page created from that form? It’s my understanding that cookies are what monitor and let the server know someones logged in.

    I’m asking here because I’m using WebLoginPE and don’t know the correct syntax and/or variable to use to record the username and submit it into the database of for future cross-referencing.

    I would definitely appreciate some assistance/criticism on this matter.
      • 4041
      • 788 Posts
      Yes, I’m sure all of the above is certainly possible. To access the current logged in user’s credentials (for further processing) use the info found in the $_SESSION variables.
      Note that Manager users (backend) and Web Users (front end) are two seperate entities so the following snippet will only show the output if you are logged in as a webuser, although if you are logged in to the manager at the same time, both arrays will be shown.
      To be able to see exactly what you have to work with, create a new snippet named SessionInfo, with the following code, log in as a Webuser and navigate to the page which has the snippet call.

      <?php
      /*     SessionInfo
      
             usage: call snippet uncached in the content section of a page
             [!SessionInfo!]
      */
      
      $output .='';
      // show this only if the user is logged in as a web user
      if(isset($_SESSION['webValidated'])){
          $output .='<p>Welcome, '.$_SESSION['webShortname'].' - you are logged in</p>';
          $output .='<p>'.print_r($_SESSION).'</p>';
      }
      return $output;
      ?>


      The $_SESSION is available no matter which login method you use (default weblogin or WebloginPE).
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 32365
        • 42 Posts
        Alright I’m going to have to check that out tomorrow when I have more time.

        Now that I know where the session information is held it seems like all I need to do have the form send the $_SESSION data to the database with the page that will be created. Then add an "if(" argument to verify the same user is logged in, if so then an extra table or div tag will be enabled.

        Thank you very much for the assistance. I’m trying to get a dynamic page submission function working with edible content. If I have an "edit" link(that only the user who created the page can see) that loads up a form to edit the right database information then it should work fine.

        This is my first time building a website using more coding than simple javascript. Up until recently I’ve been an CSS/SEO guy but I want to expand my knowledge into php and CMS driven websites.
          • 3749
          • 24,544 Posts
          I spent years trying to develop edible content but never had any luck. Let us know how it goes. wink

          Sorry, couldn’t resist. tongue
            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
            • 4310
            • 2,310 Posts
            Yummy, I want to create edible content.
              • 32365
              • 42 Posts
              Well I’ll let you all know how it goes. I’ve finally got a decent grasp on everything that needs doing in my head, so now it’s time to just type it out.

              Update: Well my form to allow users to create pages works at least. The test pages were submitted directly to the database and they showed up with the correct information in the back-end resource tree and were viewable on the live site.

              I guess the next thing to do is to is attach the user recognition and category T.V.’s to the form as well.
                • 4172
                • 5,888 Posts
                Did you see FDM - Frontend Document Manager?
                I think this can do what you are about.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 32365
                  • 42 Posts
                  Quote from: Bruno17 at Nov 16, 2009, 12:28 AM

                  Did you see FDM - Frontend Document Manager?
                  I think this can do what you are about.
                  That allows any user in a webgroup to create and edit the page though doesn’t it? I want pages that only a single user is allowed to edit.

                  Right now I have the entire page creation part of my script done and working, now I need to create the edit feature. My last idea didn’t work since I couldn’t get the javascript to work with content called from inside a php echo. I’m gonna have to brainstorm on a different approach today.
                    • 5340
                    • 1,624 Posts
                    Try this link. Maybe you can use something

                    I will do a follow up with on how you can update TVs values but basically it’s very simple.
                      • 32365
                      • 42 Posts
                      Quote from: cipa at Nov 16, 2009, 03:29 PM

                      Try this link. Maybe you can use something

                      I will do a follow up with on how you can update TVs values but basically it’s very simple.
                      Yeah the approach I’m taking is to update the values in the database directly. I think I found a solution to the edit form link.

                      Earlier I added a column to the table "modx_site_content" in the database to store the name of the user that submits a page for future reference. The html code for the link to the edit page will only be viewable if both the current $_SESSION[’webShortname’] and the shortname stored in the database are an exact match, then I send store and send a variable containing the "id" of the current "user" genereated page to the "edit" page where I use a few more database and page variables to narrow down the "mysql UPDATE" script to only change the content of the previous "user" generated page.

                      I’m still a novice at php so that might not be the best approach, but it’s all I know how to do for now. So far everything has worked now. At the moment I’m working on setting up the "edit" form text area’s to be populated with the existing content on the live "user" page. Next is to set it up so that if an "edit" page input area is blank no changes will be made to the database. For that part I’m still undecided with using more than one "submit" button for each value or not.