13 Replies Latest reply on Feb 7, 2009 4:59 PM by only1wizard

    Login and display user data

    Level 1
      I am able to setup a login page and redirect to a user page, but my problem is that I cannot filter the user page to the user logged in to display their data:

      For example:

      Login page:
      Username: JaneDoe
      Password: Hello

      -->Directs to User page (This is where I am stuck!)

      Hello, Jane Doe (or any other username)<--How can I filter to the user logged in?
      Here are your details: (Recordset Bindings)<--How can I show their details?

      Sorry if this is confusing, but thanks in advance.
        • 1. Re: Login and display user data
          Günter Schenk Level 4
          Hi,

          your recordset´s query would have to be like this:

          "SELECT username FROM usertable WHERE user_id" equals the Session Variable "kt_login_id"

          As you´ll probably be using DW`s native Recordset Builder, be sure to filter your "usertable" against the abovementioned Session Variable

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: Login and display user data
            Level 1
            Hi Gunter, Thanks, I'll try that.
            • 3. Re: Login and display user data
              Level 1
              Hi Guys.

              OK, I'm still stuck!

              This is what I see in my Recordset Window

              Table: login
              Filter: username =
              Session Variable kt_login_id
              Sort: None
              Ascending

              This works ok when I test it, but when I try and log in from the login page, it comes up blank.

              Help needed again, sorry.
              • 4. Re: Login and display user data
                Günter Schenk Level 4
                please add



                on line 1 of this page, as a manually created PHP page usually need this to make it detect the session.

                Cheers,
                Günter Schenk
                Adobe Community Expert, Dreamweaver
                • 5. Re: Login and display user data
                  Level 1
                  Hi Günther. Many thanks for this, worked perfectly.
                  • 6. Re: Login and display user data
                    zuffster
                    Guenter,

                    In regards to this discussion, I am doing something very similar except with using two tables that are or will be related. Example: I have two tables in the database:

                    user_tbl
                    -userID (primary)
                    -user_name
                    -user_pw
                    -user_email
                    AND
                    userInfo_tbl
                    -userInfoID (primary)
                    -user_company
                    -user_address
                    -user_phone
                    -userid (foreign key)

                    The customer registers first on the front-end and then can login. Given your instructions above, I can now at least display only that user's info once logged in. Once the user logs in after registration, he or she will be directed to an index.php page where there are links to 'add', 'view' and 'edit' his or her information from the userInfo table. My question is this, will I have to pass the same session variable ("kt_login_id") to every page (i.e. index.php, userInfo_add.php, userInfo_edit.php, userInfo_view.php pages...etc)? One user will be able to add multiple records to the userInfo_tbl and when he or she logs in, should be able to see all the records that the one user entered into the database.
                    • 7. Re: Login and display user data
                      Günter Schenk Level 4
                      Hi Mike,

                      ---------
                      My question is this, will I have to pass the same session variable ("kt_login_id") to every page (i.e. index.php, userInfo_add.php, userInfo_edit.php, userInfo_view.php pages...etc)?
                      ---------

                      Although that would be possible, I really can´t recommend passing Session Variables via e.g. an URL parameter.

                      This is not only insecure, but also wouldn´t make sense at all, because you can easily check against any session variable within the very same page that requires such a protection -- please have a look at my "Protecting your application: Update my Account" tutorial: http://www.guenter-schenk.com/tutorials/tutorial.php?id=8

                      Cheers,
                      Günter Schenk
                      Adobe Community Expert, Dreamweaver
                      • 8. Re: Login and display user data
                        zuffster Level 1
                        Thank a bunch Guenter for your quick response! That makes sense with the update page. When INSERTING a new record to the userInfo_tbl after the user logs in, what would be the 'proper' way or what variable type would I have to pass from the index.php page (where the links are to 'add' & 'view/update')to the userInfo_add.php page in order to connect the userID of the user_tbl to the userid (foreign) column of the userInfo_tbl. In short, I want that when that specific user inserts information into the userInfo table, it belongs to him. Would I create the Recordset this way for the userInfo_add.php:

                        SELECT* FROM userInfo_tbl
                        WHERE user.userid = SESSION VAR (kt_login_id)
                        • 9. Re: Login and display user data
                          Günter Schenk Level 4
                          Hi Mike,

                          -------
                          what would be the 'proper' way or what variable type would I have to pass from the index.php page (where the links are to 'add' & 'view/update')to the userInfo_add.php page in order to connect the userID of the user_tbl to the userid (foreign) column of the userInfo_tbl
                          -------

                          again, no need to pass the "kt_login_id" Session Variable to userInfo_add.php.

                          ------
                          I want that when that specific user inserts information into the userInfo table, it belongs to him
                          ------

                          In order to allocate the newly created record to the current user and to make this happen behind the scenes, you´ll just have to tell ADDT´s Insert Record wizard to insert the "kt_login_id" Session Variable into the respective column.

                          Here´s how to define that when doubleclicking an existing "Insert Record Transaction", clicking the "Fields" tab and selecting the "userid" column:

                          - Submit as: numeric
                          - Get value from: Session Variable
                          - variable name: kt_login_id

                          BTW, may I ask why you´re spreading the user-related information across different tables ? Honestly said, I personally use to add such columns to the existing "login" table, what makes updating stuff and querying much easier

                          Cheers,
                          Günter Schenk
                          Adobe Community Expert, Dreamweaver
                          • 10. Re: Login and display user data
                            zuffster Level 1
                            Nochmal, Vielen Dank fuer die Information! The reason that I am spreading the user information over multiple tables is because it would be more appropriate if I want to (for example) associate ONE blog-user to multiple blog-posts. I am trying to eliminate redundancy or repetitive information in my database. The userInfo and the tables were just examples. I probably should have used an example of a blog. I agree, the customer related info should be all together with in the user's table. Thanks again for all your help.
                            • 11. Re: Login and display user data
                              zuffster Level 1
                              Guenter,

                              It worked like a charm. Thanks again for all your help.
                              • 12. Re: Login and display user data
                                Günter Schenk Level 4
                                Hi Mike,

                                you´re welcome :-)

                                Cheers,
                                Günter Schenk
                                Adobe Community Expert, Dreamweaver
                                • 13. Re: Login and display user data
                                  only1wizard Level 1
                                  Hello -

                                  I have a similar problem.

                                  I have three tables that my user registration info is going into.

                                  its a 1 => 1 relationship for that schema.

                                  I was able to manually create the page like i wanted it with doing three seperate inserts.

                                  I'm a newbie to web developement. I'm more of a DBA.

                                  I recently duplicated the form that i previous created using the insert form wizard in cs4 dw.

                                  and i'm running into a problem. in the one i hard coded i used a join to return the results. but not to do the inserts.

                                  q0. if we are doing multiple inserts to different tables should we create a seperate form for that table and have the varible i.e. last_insert_id() passed to the next form to retain data redundancy on the same page?

                                  q1. are we able to do table joins in a wizard form if so how?

                                  i would prefer to create the forms useing the insert/update wizard it makes it easier when you have 25+ db schemas for one site.

                                  q2. can you point me to some qood tutorials and examples using cs4 web dev pro.

                                  if you need to look at the code i can paste, just let me know.

                                  thanks, in advance for your help.

                                  Theo Werntz II