[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Password protection/user authentication.

Posted on 2003-02-26
2
Medium Priority
?
154 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

640 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