Autor Beitrag
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: So 31.05.09 17:55 
okay danke... jetzt ne dumme frage nebenbei ;)

muss das jetzt in Form1 (unit1) oder Form2 (unit2)? und muss das IdHttp button dingen in f1 oder f2?
muss das mit dem loggin button verlinkt werden?

:oops:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 31.05.09 17:57 
Sauber wäre es, wenn du das in deinem Hauptfenster machst und das Loginfenster nur davon anzeigst, denn sonst bekommst du nur noch mehr Probleme.

Ob der Benutzer Ok gedrückt hat, bekommst du ja über den Rückgabewert von ShowModal wie gesagt, wenn du ModalResult gesetzt hast.
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: So 31.05.09 18:08 
was ist daran falsch?... verbessert mich bitte :?

ausblenden 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:
procedure TForm1.FormCreate(Sender: TObject);
begin
Form2 := TForm2.Create(nil);
  try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
    FUsername := Form2.Edit1.Text;
    FPassword := Form2.MaskEdit1.Text;
  finally
    Form2.Free;
  end;
end;



var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
<span style="color: red">  HttpLoader := TIdHttp.Create;</span> -> Nicht genügend wirkliche Parameter
  try
    PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + <span style="color: red">FUsername</span> + '&pass=' + <span style="color: red">FPassword</span>); -> undefinierter bezeicher
    if PageContents = 'erfolgreich' then
      ShowMessage('Login erfolgreich');
  finally
    HttpLoader.Free;
  end;
end;
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 15:13 
sorry wenn ich störe, aber ich wollte das fertig kriegen, nur weiß nicht wie ich es vollenden muss :roll:

könnt ihr mir noch weiterhelfen bitte :oops:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 15:16 
Die Überprüfung musst du direkt nach der Anzeige des Loginfensters in FormCreate machen. Du musst es ja ggf. erneut anzeigen, wenn der Login nicht erfolgreich war.

Wo hast du das denn jetzt hingeschrieben? Einfach so lose irgendwo hingeschmissen? :lol:
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 15:24 
mhm... ist das so jetzt ungefähr richtig??

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
  HttpLoader: TIdHttp;
  PageContents: String;
procedure TForm1.FormCreate(Sender: TObject);
begin
HttpLoader := TIdHttp.Create;
Form2 := TForm2.Create(nil);
  try
    PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + FUsername + '&pass=' + FPassword);
    if PageContents = 'erfolgreich' then
      ShowMessage('Login erfolgreich');
  finally
    HttpLoader.Free;
  try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
    FUsername := Form2.Edit1.Text;
    FPassword := Form2.MaskEdit1.Text;
  finally
    Form2.Free;
  end;
end;


nur bei HttpLoader := TIdHttp.Create; sagt er: nicht genügend wirkliche parameter... -.-

ich das ansich denn richtig zusammengefügt?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 15:32 
Das var mit den Variablendeklarationen gehört auch in die Prozedur rein, also direkt vors begin. Und dann zum Rest:
Wie wäre es mit logischem Denken? Meinst du wirklich, dass es eine gute Idee ist zuerst den Login online zu überprüfen und dann das Loginfenster anzuzeigen? :roll:

Der Fehler mit den Parametern: Da hast du wohl eine sehr alte Version von Indy. :gruebel:
Versuch als Parameter einfach mal Self.
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 15:45 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Der Fehler mit den Parametern: Da hast du wohl eine sehr alte Version von Indy. :gruebel:
Versuch als Parameter einfach mal Self.


ich versteh dich nicht ganz... ich weiß jetzt zwar nicht ob das was mit delphi7 zu tun hat aber naja, das mit den parameter und Self sagt mir leider nichts :oops: , bin noch nicht lange mit delphi am gange... ähm so sieht es jetzt bei mir aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.FormCreate(Sender: TObject);
var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
HttpLoader := TIdHttp.Creater;
Form2 := TForm2.Create(nil);
    try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
    FUsername := Form2.Edit1.Text;
    FPassword := Form2.MaskEdit1.Text;
   finally
    Form2.Free;
  try
    PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + FUsername + '&pass=' + FPassword);
    if PageContents = 'erfolgreich' then
      ShowMessage('Login erfolgreich');
  finally
    HttpLoader.Free;

  end;
end;
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 15:52 
Ohne dass du verstehst was da passiert hat das keinerlei Sinn.

Einen sehr guten Crashkurs findest du hier:
crashkurs.christian-stelzmann.de
und die neue Version speziell ab Turbo Delphi:
www.christian-stelzm...shkurs_reloaded.html

Ein weiteres gutes Online-Buch:
de.wikibooks.org/wik...grammierkurs:_Delphi

Wenn du eine Prozedur oder Funktion aufrufst, dann übergibst du da ggf. Parameter und bekommst einen Rückgabewert.
ausblenden Delphi-Quelltext
1:
function IntToStr(Value: Integer): string;					
Hier musst du einen Integerwert als Parameter übergeben und bekommst einen String zurück. Wenn du die also aufrufst:
ausblenden Delphi-Quelltext
1:
IntToStr(12);					
Dann ist 12 der erste (und hier einzige) Parameter.

Diese Grundlagen musst du dir aber selbst aneignen. Zum Beispiel mit dem Crashkurs.
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 15:56 
okay ich werd mir das mal angucken ;)... -> melde mich!
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 17:06 
hab mir das durchgelesen und die funktion des parametesrs erkannt.

user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:

Versuch als Parameter einfach mal Self.


procedure TForm1.FormCreate(Sender: TObject); wie soll ich das self denn jetzt darein bauen? das self erkennt er dann nicht, wenn ich das richtig eingesetzt habe :D

HttpLoader := TIdHttp.Create; :P
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 17:12 
ausblenden Delphi-Quelltext
1:
HttpLoader := TIdHttp.Create(Self);					
Es steht doch da, dass da der Parameter fehlt...

Und wie gesagt, liegt nur an deiner alten Version, dass das nötig ist, bei mir ist es das nicht. :P
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 17:17 
achsouuu :D, ich dachte man muss das self iwie da oben hinzufügen ;), meine schuld^^

so schaut das jetzt aus:

ausblenden 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:
procedure TForm1.FormCreate(Sender: TObject);
var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
HttpLoader := TIdHttp.Create(Self);
Form2 := TForm2.Create(nil);
    try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
    FUsername := Form2.Edit1.Text;
    FPassword := Form2.MaskEdit1.Text;
   finally
    Form2.Free;
  try
    PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + FUsername + '&pass=' + FPassword);
    if PageContents = 'erfolgreich' then
      ShowMessage('Login erfolgreich');
  finally
    HttpLoader.Free;
  end;
end;

end.


das programm erwartet jetzt aber beim letzten "end." ein ",". habe schon vorher ein end; weggemacht und so, aber das hat iwie nichts gebracht!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 17:23 
Rück richtig ein, statt den Quelltext nur so hinzuschleudern, dann siehst du auch warum die Meldung kommt... :roll:

Die Abfrage gehört nicht in das finally, sondern z.B. davor. Aber ich rücke einmal nur korrekt ein...
ausblenden 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:
procedure TForm1.FormCreate(Sender: TObject);
var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
  HttpLoader := TIdHttp.Create(Self);
  Form2 := TForm2.Create(nil);
  try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
      FUsername := Form2.Edit1.Text;

    FPassword := Form2.MaskEdit1.Text;
  finally
    Form2.Free;
    try
      PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + FUsername + '&pass=' + FPassword);
      if PageContents = 'erfolgreich' then
        ShowMessage('Login erfolgreich');
    finally
      HttpLoader.Free;
    end;
  end;


end.
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 17:29 
okay danke :D
wenn ich jetzt aber immer noch kein name eingebe und auf login klicke, geht er trotzdem weiter...
den teil hab ich nicht wirklich verstanden bzw wie ich das einfügen muss oder generell wie man das da hinschreibt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 17:31 
Das musst du nach dem ShowModal eben alles prüfen:
Wurde Ok gedrückt? (ist ja schon drin)
Sind die Felder ausgefüllt?
Ist der Login erfolgreich?

Und wenn da ein Fehler auftaucht, musst du ggf. das Loginfenster erneut anzeigen, einen Fehler anzeigen, ...
helmesb04 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Mo 01.06.09 17:38 
achso ok... ähm, ich bin nicht so der pro dadrin, wie kann ich das denn abfragen ob die felder ausgefüllt sind und ob der account und das pw von der website richtig sind? also ob der login erfolgreich war?

hast du ne n beispiel?

sry das ich immer so blöd frage
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 17:51 
ausblenden Delphi-Quelltext
1:
2:
if frmLoginWindow.edtPassword.Text = '' then
  ShowMessage('Kein Passwort angegeben');
Und so weiter. Du musst natürlich ggf. mehr machen als nur nen Fehler anzuzeigen.
kulka1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Mo 01.06.09 18:23 
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:
procedure TForm1.FormCreate(Sender: TObject);
var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
  HttpLoader := TIdHttp.Create(Self);
  Form2 := TForm2.Create(nil);
  try
    if Form2.ShowModal = mrOk then // Rückgabewert ggf. prüfen
      FUsername := Form2.Edit1.Text;
     FPassword := Form2.MaskEdit1.Text;

  if Form2.Edit1.Text = '' then
  ShowMessage('Kein Benutzernamen angegeben');

  if Form2.MaskEdit1.Text = '' then
  ShowMessage('Kein Passwort angegeben');

  finally
    Form2.Free;
    try
      PageContents := HttpLoader.Get('http://foliga.de/login.php?name=' + FUsername + '&pass=' + FPassword);
      if PageContents = 'erfolgreich' then
        ShowMessage('Login erfolgreich');
    finally
      HttpLoader.Free;
    end;

  repeat Form2.ShowModal
  until PageContents =
  end;


ich wollte mit hilfe einer "repeat until" schleife das login fenster so oft wieder erscheinen lassen (wenn ein falscher name und passwort eingegeben wurde) bis der login geklappt hat. allerdings weiß ich nicht was nach dem = in zeile 30 hinmuss!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 01.06.09 18:27 
Also irgendwie geht hier der logische Ablauf total durcheinander...
Was passieren muss ist doch:
Solange das Loginfenster anzeigen bis entweder der Benutzer abbricht oder bis der Login erfolgreich war.

Zur Prüfung muss (wenn Ok gedrückt wurde) geschaut werden, ob beide Felder ausgefüllt sind. Oben im Quelltext wird nur die erste Zeile nach dem ShowModal in dem if ausgeführt, der Rest immer!
Und wenn beide ausgefüllt sind, dann wird der Login versucht. Und wenn der erfolgreich war, wird ein Flag gesetzt (boolsche Variable z.B.), dass die Schleife beendet werden kann.