Autor Beitrag
somebody
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Mi 16.05.07 19:49 
ich habe mal versucht ein passwortprogramm zu machen, also wenn man ein bestimmtes passwort bei einem bestimmten benutzer eingibt, das dann auf einem panel steht, guten tag mr. x. und ein shape grün wird. das klappt auch soweit, aber jetzt wollte ich versuchen, dass man das passwort auch ändern kann, aber da hab ich keinen plan, das hier ist der bisherige quelltext.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    Panel1: TPanel;
    Button1: TButton;
    Shape1: TShape;
    Timer1: TTimer;
    Label3: TLabel;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  timer : integer;
  person : integer;
  passwort1 : integer;
  passwort2 : integer;
  passwort3 : integer;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
     timer1.enabled := true;

     if edit1.Text = 'Maier' then
     begin
          if edit2.text = 'p1' then
          begin
               panel1.caption := 'Guten Tag Herr Maier';
               shape1.brush.color := cllime;
               person := 1;
               edit3.visible := true;
               button2.visible := true;
          end
     else
         begin
              panel1.caption := 'Zugriff verweigert';
              shape1.brush.color := clred;
         end;
     end;

     if edit1.Text = 'Müller' then
     begin
          if edit2.text = 'p2' then
          begin
               panel1.caption := 'Guten Tag Herr Müller';
               shape1.brush.color := cllime;
               person := 2;
               edit4.visible := true;
               button2.visible := true;
          end
     else
         begin
              panel1.caption := 'Zugriff verweigert';
              shape1.brush.color := clred;
         end;
     end;

     if edit1.Text = 'Otto' then
     begin
          if edit2.text = 'p3' then
          begin
               panel1.caption := 'Guten Tag Herr Otto';
               shape1.brush.color := cllime;
               person := 3;
               edit5.visible := true;
               button2.Visible := true;
          end
     else
         begin
              panel1.caption := 'Zugriff verweigert';
              shape1.brush.color := clred;
         end;
     end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
     timer := timer +1;
     if timer = 5 then
     begin
          edit1.text := '';
          edit2.text := '';
          panel1.caption := '';
          shape1.brush.color := clwhite;
     end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin

end;

end.


danke jetzt schon mal.
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Mi 16.05.07 19:59 
Nun, du schreibst ja als Passwortabfrage immer:
ausblenden Delphi-Quelltext
1:
  if edit2.text = 'p1' then					

Jetzt ersetzt du das 'p1' einfach mit einer Variable vom Typ String, z.B:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  psw1: String;
//...
  if edit2.text = psw1 then

Jetzt musst du nur noch dafür sorgen, dass beim Starten des Programmes das Passwort z.B. aus einer Datei geladen wird, und beim Ändern des Passwortes neu in die Datei geschrieben wird.

PS: Du bist dir aber schon im klaren, dass diese Abfrage in der Form keinerlei Sicherheit bietet. Möchte ich nur mal erwähnen.
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Mi 16.05.07 20:11 
wenn psw1 in var string ist, wie leitet man danne in text von einem edit feld in die variable psw1? mit strtoint geht es jedenfalls net.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mi 16.05.07 20:14 
Beides ist n String, also kannstes direkt zuweisen, ohne StrToInt. Das brauchst du nur, wenn das, dem zugewiesen wird eine Ganzzahl ist.

Du kannst natürlich auch gleich beim uberprüfen des Passwortes mit dem Edit in dem das richtige PW steht vergleichen.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Mi 16.05.07 20:27 
Ah, thx.