|
DesiMcK -> RE: Unique user ID login needs to make certain database info available (6/10/2008 15:25:35)
|
Hi, this is how my system works. I have a db table that is called tblUsers. It contains the staff details. Each teacher has a three letter UNIQUE ID eg - I am DMC. When a teacher logs in I check their credientials - similar to your login page. I have set the teacher's Username as their unique ID. This way I can use the username throughout the session. I create a session variable and the call it during the sql statements. Does that make sense? So basically, on my login check page I use: strSQL = "SELECT * FROM tblUsers WHERE tblUsers.UserID ='" & strUserName & "'" 'Query the database rsCheckUser.Open strSQL, strCon 'If the recordset finds a record for the username entered then read in the password for the user If NOT rsCheckUser.EOF Then 'Read in the password for the user from the database If (Request("txtUserPass")) = rsCheckUser("Password") Then 'If the password is correct then set the session variables Session("UserID") = rsCheckUser("UserID") So thoroughout my db I use this UserID. For example tblCLass has two fields, UserID, ClassID. If I want to list the classes that a teacher has I would query tblClass which sql like: "SELECT * FROM tblCLass WHERE UserID = '" & Session("UserID") & "'"
|
|
|
|