9 Replies Latest reply on Apr 19, 2013 10:11 AM by bregent

    Display user info from Db after login

    ghfsdjygdg Level 1

      Hi,

       

      I would like to be able to reach certain user info on my page. (after login)

      The page is set with different insert forms, and I would like to auto add some info, like userID, address etc..

      -instead of the user having to add this himself.

       

      Remember back in the days you could add a few lines directly on the login page, like this:

      http://www.dmxzone.com/forum/topic/23442/?highlight=sarre

      -but that doesn't seem to be the case anymore.

       

      Does anybody know of a good and perhaps easy way to do this?

       

      Regards,

      Chris Sen

       

      DWCS5, Access DB

        • 1. Re: Display user info from Db after login
          bregent Most Valuable Participant

          Could you explain the workflow in more detail?

           

          Also, these posts belong in the app dev forum.

          • 2. Re: Display user info from Db after login
            ghfsdjygdg Level 1

            Hi, sorry for being so unclear. (and posting in the wrong forum)

             

            I have a database with userinfo, table Users.

            What I would like to do is extract additional information on the person logging in.

            Information that is already saved in the db, like password, address, userid etc

             

            What I was trying to explain in the post above is that I want to use some of this

            information in forms as hidden fields, so that the user dont have to add this information by him/herself.

             

            The link above shows how this could be done in DWMX, adding sessions, but the Login User behavior

            have changed a bit since then so that example don't work on CS5.

            • 3. Re: Display user info from Db after login
              bregent Most Valuable Participant

              It's best to stay away from server behaviors as they are out dated and being removed in the next version. You could store the data in session variables, or obtain it on-the-fly during form processing. What is the function of the form that you want to add these hidden fields to?

              1 person found this helpful
              • 4. Re: Display user info from Db after login
                ghfsdjygdg Level 1

                The form is being used to store information on incoming tests at work.

                Each user is storing this information through a website (asp) and inserting the information to an Access Db.

                To make the process easier I wanted the userinfo to be added automatically to the form through hidden fields.

                Linking each unique test to one unique user.

                 

                Could you perhaps give me an example on how to store the UserID in a session variable?

                A working example would open up my brain.

                • 5. Re: Display user info from Db after login
                  bregent Most Valuable Participant

                  Setting a session variables is as simple as:

                   

                  <%
                       session("UserID") = rsLogin.Fields.Item("UserID")


                  %>

                   

                   

                  The user ID is probably the only hidden field you need, since there is not much sense is storing other data that is already in the user table.

                  • 6. Re: Display user info from Db after login
                    ghfsdjygdg Level 1

                    You're right about that.

                     

                    Thank you for showing me how to write the session.

                     

                    So let me see if I get this right; the session is set after the user is logged in, the way you just showed me.

                    Can I call the session with a response.write in a hidden field?

                    If this is correct what would be the syntax for this?

                    • 7. Re: Display user info from Db after login
                      osgood_ Level 8

                      ggsetherthjrj wrote:

                       

                      So let me see if I get this right; the session is set after the user is logged in, the way you just showed me.

                       

                      Yes that's correct.

                       

                      ggsetherthjrj wrote:

                      Can I call the session with a response.write in a hidden field?

                      ?

                       

                      I dont know what the correct way of doing it in asp is but in php you would just echo the SESSION userID in the hidden field:

                       

                      <input type="hidden" userID="<?php echo $_SESSION['userID']; ?>" id="userID" />

                       

                      So whatever you do in asp to write something on the page replace the above with that (maybe like below)

                       

                       

                      <input type="hidden" userID="<%  Response.Write session['userID'] %>" id="userID" />

                       

                       

                      1 person found this helpful
                      • 8. Re: Display user info from Db after login
                        ghfsdjygdg Level 1

                        Wonderful, thanks to both of you for helping me out, much appreciated!

                         

                        Regards,

                        Christian

                        • 9. Re: Display user info from Db after login
                          bregent Most Valuable Participant

                          A shorthand version would be:

                           

                          <input type="hidden" userID="<%  = session['userID'] %>" id="userID" />