?
Solved

Password protection/user authentication.

Posted on 2003-02-26
2
Medium Priority
?
152 Views
Last Modified: 2010-04-04
Hi everyone,
I would like to know, how can I authenicate a user(s) (with username and password) in delphi.
I have got a list of usernames and passwords on a Paradox table database. I want a program which checks the username and the correspoding password provided (by a user) against the database, and if they are correct then the user is allowed to login. However, if the username and the password provided are incorrect, then the program should display a error message saying 'Invalid input' or whatever.
 
An Delphi example with source would be great.
 
Cheers..
 
P.S. Remember I am usind a Paradox table database.
0
Comment
Question by:mr_delphi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
krukmat earned 300 total points
ID: 8029545
try this:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    txtUsername: TEdit;
    txtPassword: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Table1: TTable;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    Table1.Close;
    Table1.Filter:='User= '+quotedstr(txtUsername.Text)+' and Pass ='+quotedstr(txtPassword.Text);
    Table1.Filtered:=true;
    Table1.Open;

    if Table1.RecordCount=1 then
    begin
      ShowMessage('Welcome '+txtUsername.Text);
      Application.Terminate;
    end
    else
    begin
      ShowMessage('Error. Retry');
      txtUsername.SetFocus;
    end;
   finally
    Table1.Close;
   end;
end;

end.
0
 

Author Comment

by:mr_delphi
ID: 8029636
Thanks..
That was simple and easy to follow answer. Worked! :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question