Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: delphi login code  (Read 7742 times)

0 Members and 1 Guest are viewing this topic.

malditcha87

  • Guest
delphi login code
« on: March 16, 2009, 04:00:14 PM »
I am just new in delphi and i had a hard time in using it. One of my problem is the login form which has 3 users of different privileges. The code I have has plenty of errors and I can't still pinpoint the correct code for it. I hope you could check it and give me some feedback about it.

Below is the my code:

procedure Tform_login.Button1Click(Sender: TObject);
var
form:Tform_studhome;
form:Tform_phyhome;
form:Tform_homestaff;
username, password, privelege :String;

begin
zquery1.SQL.Clear;
zquery1.SQL.Add ('select username, password from account where username= '''+edit1.Text+'''');
zquery1.Active := true;
username := zquery1.Fields[1].AsString;
password := zquery1.Fields[2].AsString;

if ((username = edit1.Text) and (password = edit2.Text))
then begin
ShowMessage('Login Successful!');
zquery1.Active :=True;
zquery1.SQL.Add('select privelege, user_idno from account where username = '''+edit1.Text+'''');
privelege := zquery1.Fields[3].AsString;

if(privelege = 'student')
then begin
form:=Tform_studhome.Create(self);
form.Show;
close;
end

else
if(privelege = 'physician')
then begin
form:=Tform_phyhome.Create(self);
form.Show;
close;
end

else
if(privelege = 'staff')
then begin
form:=Tform_homestaff.Create(self);
form.Show;
close;
end

end;

end;



Thanks and more power. ;)