Mysql passing Login data to another form

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
drama22
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 12.08.2014, 09:49

Mysql passing Login data to another form

Post by drama22 »

i have asked this question on Stackoverflow but with no luck with answers , here is my question

down vote favorite


i have created 2 forms A login form & A main form i successfully logged in To the main form

here is the code that i use to login

Code: Select all

SQL := Tloginclass.Create;
  try
    SQL.Login:= trim(Usrnm.Text);
    SQL.passwd := trim(passwd.Text);
    if SQl.logins then
     begin
      LoginSuccess := True;
     end
i retrieve and validate logins from a unit class wich is Tloginclass ,,

but now how to i set the data for each user logged in to the main form ?

i try somthing like this after login

Code: Select all

//this is for list users
Mainform.list.Items.Add(SQL.Login); 
but this is not logical because this showing only text how the application know the differents between user who loggedin like there is bob and martin and james ,etc are online now and read there user names ? any idea about this iam trying to understand the logic of this concept , how to implement the tracking of online users. Second is how to enable/disable some functionality of application based on the specific user.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Mysql passing Login data to another form

Post by marsupilami »

Hello drama22,

for my applications I usually keep a table of users with their specific access rights. On startup the application reads these rights from the database into a crentral data module and the data module then has a function to check wether a user has a specific right. This function can then be called from other forms to check wether to remove buttons or disable buttons and things like that.

If you want to know which users are logged into your application you will have to ask your database about this because usually this is the only shared ressource between the instances of your program.

Best regards,

Jan
drama22
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 12.08.2014, 09:49

Re: Mysql passing Login data to another form

Post by drama22 »

marsupilami wrote:Hello drama22,

for my applications I usually keep a table of users with their specific access rights. On startup the application reads these rights from the database into a crentral data module and the data module then has a function to check wether a user has a specific right. This function can then be called from other forms to check wether to remove buttons or disable buttons and things like that.

If you want to know which users are logged into your application you will have to ask your database about this because usually this is the only shared ressource between the instances of your program.

Best regards,

Jan
can You show example code for this .
Post Reply