Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - User Management for an Internet Access Con...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

User Management for an Internet Access Control Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-22

    Table of Contents:
  • User Management for an Internet Access Control Application
  • User Management Module
  • User Management Module Explained
  • Stats Page

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    User Management for an Internet Access Control Application - User Management Module Explained


    (Page 3 of 4 )

    This module does three things. First, it prepares the form for user input, and then it checks that all the fields in the form is updated. The newly inputted data is then posted to the database and a confirmation message is displayed, stating that a new user has been created. Let’s look at the code that makes each of these three steps happen.

    The first procedure checks that the administrator entered all the required information:

    procedure TForm6.BitBtn1Click(Sender: TObject);

    begin

    The first part of the code checks that the administrator entered all the required information. This information comprises the user's name, password, etc.:


    if (edname.Text = '') OR (eduname.Text = '') OR (edupass.Text = '') OR (edupass2.Text = '') OR (edupass.Text <> edupass2.Text) then begin


    If the administrator leaves out any of the information, an error message is displayed informing her of it:

    messagedlg('Please ensure that you fill in all the fields and that the password fields are the same.',mtInformation,[mbOK],0);

    exit;

    end

    If the administrator has entered all the information correctly, it is posted to the database using the insert property of the ado component:

    else begin

    ado1.TableName:='users';

    ado1.Active := True;

    ado1.Insert;

    ado1.FieldByName('name').AsString := edname.Text;

    ado1.FieldByName('username').AsString :=eduname.text;

    ado1.FieldByName('password').AsString := edupass.text;

    ado1.FieldByName('Alevel').AsString :=cb.Text;

    ado1.Post;

    end;

    end;

    A confirmation message is then displayed as the final step in this process:

    procedure TForm6.ado1AfterPost(DataSet: TDataSet);

    begin

    messagedlg(edname.Text + ' has now been created.',mtinformation,[mbOK],0);

    end;


    The next option in the user management module covers changing a staff member's password in the database. The code should be familiar to you by now. The following takes place in this module: first, all the names of the users in the database are retrieved and stored in a combo box. You have to select the name of the user whose details you want to change, and then add the new fields to the form. The changes are posted to the database and a confirmation message is displayed. Below is the code for the module:

    unit changepassword;


    interface


    uses

    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

    Dialogs, StdCtrls, Buttons;


    type

    TForm7 = class(TForm)

    gb1: TGroupBox;

    cb: TComboBox;

    StaticText1: TStaticText;

    newpass: TEdit;

    StaticText3: TStaticText;

    StaticText4: TStaticText;

    newpass2: TEdit;

    BitBtn1: TBitBtn;

    BitBtn2: TBitBtn;

    procedure BitBtn2Click(Sender: TObject);

    procedure FormShow(Sender: TObject);

    procedure cbSelect(Sender: TObject);

    procedure BitBtn1Click(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    end;


    var

    Form7: TForm7;

    pname:string;

    implementation


    {$R *.dfm}

    uses Logon;

    procedure TForm7.BitBtn2Click(Sender: TObject);

    begin

    close;

    end;


    procedure TForm7.FormShow(Sender: TObject);

    begin

    gb1.Enabled:=false;

    form3.q.close;

    form3.q.SQL.Text:='SELECT name from users';

    form3.q.Open;

    while not form3.q.Eof do begin

    cb.Items.Add(form3.q.fieldbyname('name').AsString);

    form3.q.Next;

    end;


    end;


    procedure TForm7.cbSelect(Sender: TObject);

    begin

    pname:=cb.Text;

    gb1.Enabled:=true;

    end;


    procedure TForm7.BitBtn1Click(Sender: TObject);

    begin

    //check to see that all password fields are filled in

    if (newpass.Text = '') OR (newpass2.Text = '' ) OR (newpass.Text <> newpass2.Text) then begin

    messagedlg('Please ensure that you fill in all the fields and that both new password fields are the same.',mtInformation,[mbOK],0);

    exit;

    end else

    begin

    form3.q.close;

    form3.q.SQL.text:='INSERT INTO users SET password=:newpass WHERE name=:thename';

    form3.q.Parameters.ParamByName('thename').Value:=pname;

    form3.q.Parameters.ParamByName('newpass').Value:=newpass.text;

    form3.q.ExecSQL;

    messagedlg('The password for ' + pname + 'has been changed.',mtInformation,[mbOK],0);

    end;

    end;

    end.



    More Delphi-Kylix Articles
    More By David Web


     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT