2
I set up a login screen where the user must enter login and password with the code below:
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 password login is as follows:
procedure TFMLogin.lbl_cadastroClick(Sender: TObject);
begin
UDM.ADODSLogin.open;
UDM.ADODSLogin.Insert;
FMCad_Login.showmodal;
end;
after filling in 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 record goes into the database
however I have 3 registered users, and I can only enter with the last one that was inserted and after a while I can only access with the ID n° 1
Where am I going wrong?
has how to display the login table structure ?
– Junior Moreira
added the question
– Guilherme Lima
error or simply not log ?
– Junior Moreira
do not log, give the message I put of password or incorrect user
– Guilherme Lima
opens the database and takes a "print" and shows the data as it is in the database, if possible table details, field type etc, id, primary key!
– Junior Moreira
edited the question
– Guilherme Lima
Ok, if the data is recorded correctly, we will change this here and see if something happens: Fmhome.ADOLogin.SQL.add('Select * from login Where usuario = :user AND password = :password'); Remove double quotes!
– Junior Moreira
negative, other passwords do not work, the one with Id_login 1 works.
– Guilherme Lima
give a Truncate in this table and register 1 new user! Then register another different user
– Junior Moreira
there’s something wrong, if I put anything in the login field and the correct password, it enters the system
– Guilherme Lima
Fmhome.ADOLogin.SQL.add('Select FIRST 1 * FROM login Where user = :user AND password = :password'), just tested here, this works too
– Junior Moreira
remains the same...
– Guilherme Lima