Results 1 to 9 of 9

Thread: Delphi, MySQL and Login!!!

  1. #1
    Join Date
    Jul 2010
    Posts
    37

    Delphi, MySQL and Login!!!

    Hi! I would like to making a login form for my Delphi application which basically get information such as login and password from web-site MySQL database. Obviously, the web-site is mine.

    There are many users. If there is no such user in the database, then the application must say that there is no such user or this user is not registered. I would like to do it with some dialog screen which can be closed later.

    Waiting for your suggestions.
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2007
    Posts
    2,291

    Re: Delphi, MySQL and Login!!!

    You can start by creating the main form of the application by creating a new Delphi project containing one form. This form is, by design, the main form.
    If you change the name of the form to "TMainForm" and save the unit as "main.pas", the project's source code looks like (the project was saved as "PasswordApp"):
    Code:
     program PasswordApp;
     
     uses
       Forms,
       main in 'main.pas' {MainForm};
     
     {$R *.res}
     
     begin
       Application.Initialize;
       Application.CreateForm(TMainForm, MainForm) ;
       Application.Run;
     end.
    More information here.

  3. #3
    Join Date
    Jul 2010
    Posts
    37

    Re: Delphi, MySQL and Login!!!

    You didn't get me. I need that the logins and passwords were taken from my web-site's SQL. Because, there will be many users. I don't think that it will work in such case.

  4. #4
    Join Date
    Mar 2010
    Posts
    20

    Re: Delphi, MySQL and Login!!!

    I am also trying to make a program for which i need a login screen, the first form has two edit boxes and two buttons with the cancel button that closes the program and the login button that checks username and password if it is correct or not. However, I keep getting an error for the code that i have written for the login button every time i click on it. I hope some one can help me by correcting the below code:

    Code:
    begin
    If edit1.Text='Admin' Then
    Begin
    Edit1.Readonly:=true;
    end
    else
    If edit2.Text='1234' Then
    Begin
    form2.Visible:=True;
    end
    else
    Begin
    ShowMessage('Incorrect username and password');
    end;

  5. #5
    Join Date
    Jul 2010
    Posts
    37

    Re: Delphi, MySQL and Login!!!

    I don't see any code that belongs to SQL.

  6. #6
    Join Date
    Jul 2010
    Posts
    37

    Re: Delphi, MySQL and Login!!!

    Anyone, who can answer?!

  7. #7
    Join Date
    Jul 2006
    Posts
    218

    Re: Delphi, MySQL and Login!!!

    I happened to use Delphi language when I was in college for my thesis. Much better to HTML Code and much simpler. Try this one for your Deplhi Code : http://delphi.about.com/od/fullcodep...i_Projects.htm and http://www.firmmonster.com
    ~*~Silent~Kid~*~
    "To The World You May Be Just One Person, But To One Person You May Be The World"

  8. #8
    Join Date
    Jul 2010
    Posts
    1

    Re: Delphi, MySQL and Login!!!

    The following code goes into your project file :

    Application.Initialize;
    Application.Title := 'XYZ';
    frmLogin := TfrmLogin.Create(Application);
    frmLogin.ShowModal;
    Application.CreateForm(TMainForm, mainForm);
    Application.Run;


    The following code goes into the OnClick() event of your login screen for the Login button. You need to set the database/connection properties for the query :


    function TfrmLogin.ValidateLogin: Boolean;
    var
    bValidated : Boolean;
    begin
    try
    bValidated := False;
    try
    qryLogin.SQL.Clear;
    qryLogin.SQL.Add('Select user_login');
    qryLogin.SQL.Add(' , User_Password');
    qryLogin.SQL.Add(' from user');
    qryLogin.SQL.Add(' where user_login = Upper(:UserLogin)');
    qryLogin.SQL.Add(' and User_Password = Password(:UserPassword)');
    qryLogin.SQL.Add(' and User_IsActive = ''Y''');
    qryLogin.SQL.Add(' and User_LoginExpDate > Sysdate()');
    qryLogin.Parameters[0].Value := UpperCase(Trim(edtLoginName.Text));
    qryLogin.Parameters[1].Value := Trim(edtPassword.Text);
    qryLogin.Open;
    if qryLogin.RecordCount > 0 then begin
    bValidated := True;
    showmessage('Valid Login');
    end;
    except
    on E : Exception do begin
    ShowMessage('Exception in TfrmLogin.ValidateLogin: ' + E.message);
    end;
    end;
    finally
    result := bValidated;
    end;
    end;

    In the above query, I have used the 'Password' function to encrypt the password. You may remove it if you don't want to encrypt the password.

    Hope that helps you.

  9. #9
    Join Date
    Jul 2010
    Posts
    37

    Re: Delphi, MySQL and Login!!!

    Thanks, I will try it tomorrow.

Similar Threads

  1. Replies: 4
    Last Post: 13-01-2011, 01:08 AM
  2. Delphi, TWebBrowser, Web-Site Login?!
    By alex198555 in forum Software Development
    Replies: 1
    Last Post: 28-07-2010, 11:11 AM
  3. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  4. How to Login using borland delphi 7.0
    By nanakofiboafo in forum Software Development
    Replies: 1
    Last Post: 22-08-2009, 11:58 AM
  5. What is Delphi Getprocessbyid? How it is to be used?
    By Ground 0 in forum Software Development
    Replies: 3
    Last Post: 11-08-2009, 02:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,675,252,020.01543 seconds with 18 queries