I installed a login screen where the user must enter login and password with the following code:
procedure TFMLogin.Img_confClick(Sender: TObject);
var verif: boolean;
begin
FMHome.ADOLogin.SQL.add('Select * from "login" where "usuario" = :usuario AND "senha" = :senha');
FMHome.ADOLogin.Parameters.ParamByName('usuario').Value := edt_usuario.Text;
FMHome.ADOLogin.Parameters.ParamByName('senha').Value := edt_senha.Text;
FMHome.ADOLogin.Open;
try
if Not (FMHome.ADOLogin.isEmpty) then
begin
Modalresult := mrok;
verif := true;
end
else
begin
Application.MessageBox('Senha ou usuário incorretos!','Atenção',MB_OK+MB_ICONINFORMATION);
edt_usuario.Clear;
edt_senha.Clear;
edt_usuario.SetFocus;
verif := False;
end;
finally
FMHome.ADOLogin.Close;
end;
if (verif = true) then
begin
FreeAndNil(FmLogin); //Libera o form de Login da memória
Application.CreateForm(TFmHome, FmHome); //Cria a janela main
Application.Run; //Roda a aplicação
end;
end;
To create a new user if the person does not have the login password is as follows:
procedure TFMLogin.lbl_cadastroClick(Sender: TObject);
begin
UDM.ADODSLogin.open;
UDM.ADODSLogin.Insert;
FMCad_Login.showmodal;
end;
After completing the fields the step is to confirm:
procedure TFMCad_Login.Img_confClick(Sender: TObject);
begin
UDM.ADODSLogin.Post;
end;
Login table:
At this point, the registry goes to the database
But I have 3 registered users, and I can only enter the last one that was inserted and after a while I can only access with ID # 1
Where am I going wrong?