After learning a few commands on Borland Delphi 7 in my previous post, will now be discussed regarding making application security in the form of manufacturing Login Form.
Login Form is used to provide security restrictions on an application, in which only certain users can use the application that we created. So not all or any charcoal can use the application.
The command used for the manufacture of this form all the basics have been covered in previous posts. Here we use ShowMessage, MessageDlg, If Statement, and some additional events that might just discussed.
Login Form logic of this system are:
If the correct Username and Password, then login information dialog will appear Success, and will appear again Dialog will Exit what Next (this only as an example).
If you make a mistake entering your Username and Password less than three times, still able to login again. If the third time is still incorrect, then it will exit the application.
Draft Login Form is as follows:
There are several procedures that have not been described in the previous post on OnKeypress Events
if key = #13 then
edt2.SetFocus;
The above command is used to move to another component when pressing the Enter key on the keyboard. For example, if the cursor is positioned over the Username, after entering Username at press Enter then the cursor will go on edt2 (Edit2).
The main procedure in this project is the Login Form at the time of pressing the Login button. The procedure is as follows:
[sociallocker]
procedure TForm1.btn1Click(Sender: TObject);
var
username, password : String;
buttonSelected : Integer;
begin
// Variable for username and password
username := 'learning';
password := 'delphi';
// Alert if Username empty
if edt1.Text = '' then
begin
ShowMessage('Please enter Username.....!!!!');
edt1.SetFocus;
Exit;
end;
// Alert if Password empty
if edt2.Text = '' then
begin
ShowMessage('Please enter Password.....!!!!');
edt2.SetFocus;
Exit;
end;
// Process execute Username and Password
if (edt1.Text = username) and (edt2.Text = password) then
begin
// Alert / Info if Username and Password true
ShowMessage('Login Success.....'+ chr(13) +'Next Form here...');
// Dialog box if Username and Password true (Exit or not)
buttonSelected := MessageDlg('Login Success....., do you want to exit?',mtCustom,
[mbYes,mbNo], 0);
if buttonSelected = mrYes then
Application.Terminate;
end
else
begin
// How many wrong execute Username and Password ()
wrglogin := wrglogin + 1;
// If Wrong Username and Password less 3 than still can execute login
if wrglogin < 3 then
begin
ShowMessage('Username or and Password Wrong.....');
edt1.text := '';
edt2.text := '';
edt1.SetFocus;
end
else
// If Wrong Username and Password more 3 than exit application
begin
ShowMessage('Sorry not authorized.....');
Application.Terminate;
end;
end;
end;
From the source above described functions of the existing orders in the remark that existed at the source.
The following display results:
Display if the Username or Password is empty
Display if the Username or Password is wrong
Display if the Username or Password 3 time is wrong
Display if the next Login Success
Thus the discussion about creating a Login Form post in Borland Delphi 7. May be useful for you.
For more details, please download the following example source code
[/sociallocker]
-=Thank.you=-
How To Make Login Form for Security Application on Borland Delphi 7
0 comments:
Post a Comment