Hello all, we are building a database application, but don't know to check for a user password from the table. here is my code,
this is the login form, i populate the combobox with availabe recods from the database
void __fastcall Tlogin::FormActivate(TObject *Sender)
{
datamodule1->Query1->SQL->Clear();
datamodule1->Query1->SQL->Add("SELECT * FROM User"
datamodule1->Query1->Open();
ComboBox1->Items->Add(datamodule1->Query1->FieldByName("UserName"->AsString);
while (datamodule1->Query1->FindNext())
{
ComboBox1->Items->Add(datamodule1->Query1->FieldByName("UserName"->AsString);
}
}
the user chooses a user name, we only have two in the table and will not use more, one with full permissions, and the other with partail use of the program. When the user chooses a user, types in password in the edit box, and press ok
void __fastcall Tlogin::OKClick(TObject *Sender)
{
datamodule1->Query1->SQL->Clear();
datamodule1->Query1->SQL->Add("SELECT * FROM User"
datamodule1->Query1->Open();
if ((ComboBox1->Text == "Manager" && (login->Edit1->Text == datamodule1->Query1->FieldByName("UserPassword"->AsString))
{
ComboBox1->Text =="Manager";
login->Hide();
mainmenu->ShowModal();
}
else if ((ComboBox1->Text == "Assistant" && (login->Edit1->Text == datamodule1->Query1->FieldByName("UserPassword"->AsString))
{
login->Hide();
mainmenu->Image7->Hide();
mainmenu->Button6->Hide();
mainmenu->Button7->Hide();
mainmenu->Button2->Hide();
mainmenu->Label1->Hide();
mainmenu->Label7->Hide();
mainmenu->Label6->Hide();
mainmenu->Label5->Hide();
mainmenu->ShowModal();
}
}
how to take all the passowrds from the tables, and match the user name with the password? coz in our code, it only takes the first password from the table which is the manager's password.
plx help, tnx guys
this is the login form, i populate the combobox with availabe recods from the database
void __fastcall Tlogin::FormActivate(TObject *Sender)
{
datamodule1->Query1->SQL->Clear();
datamodule1->Query1->SQL->Add("SELECT * FROM User"
datamodule1->Query1->Open();
ComboBox1->Items->Add(datamodule1->Query1->FieldByName("UserName"->AsString);
while (datamodule1->Query1->FindNext())
{
ComboBox1->Items->Add(datamodule1->Query1->FieldByName("UserName"->AsString);
}
}
the user chooses a user name, we only have two in the table and will not use more, one with full permissions, and the other with partail use of the program. When the user chooses a user, types in password in the edit box, and press ok
void __fastcall Tlogin::OKClick(TObject *Sender)
{
datamodule1->Query1->SQL->Clear();
datamodule1->Query1->SQL->Add("SELECT * FROM User"
datamodule1->Query1->Open();
if ((ComboBox1->Text == "Manager" && (login->Edit1->Text == datamodule1->Query1->FieldByName("UserPassword"->AsString))
{
ComboBox1->Text =="Manager";
login->Hide();
mainmenu->ShowModal();
}
else if ((ComboBox1->Text == "Assistant" && (login->Edit1->Text == datamodule1->Query1->FieldByName("UserPassword"->AsString))
{
login->Hide();
mainmenu->Image7->Hide();
mainmenu->Button6->Hide();
mainmenu->Button7->Hide();
mainmenu->Button2->Hide();
mainmenu->Label1->Hide();
mainmenu->Label7->Hide();
mainmenu->Label6->Hide();
mainmenu->Label5->Hide();
mainmenu->ShowModal();
}
}
how to take all the passowrds from the tables, and match the user name with the password? coz in our code, it only takes the first password from the table which is the manager's password.
plx help, tnx guys