Autor Beitrag
CodeRed
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 2000
D7 Pers
BeitragVerfasst: So 21.11.04 18:06 
hi!
ich weiß, dass es dieses Thema schon oft gab, aber ich hab bis jetzt keine Lösung gefunden. Desshalb wäre ich froh, wenn ihr mir helfen könntet.
ich hab zwei verschiedene PHP-Buttons auf einer Seite. Wie kann ich nun in Delphi den richtigen der Beiden drücken??

Der Quellcode sieht so aus:


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
<td align=center height=20><form action="aendern.php" method="POST">
 <input type="hidden" name="kommentieren" value="Kommentieren">
 <input type="hidden" name="form" value="">
 <input type="Submit" name="aendern" value="Kommentieren" class="formular_transp">
</form>
</td>
</tr>

<tr>
 <td align=center height=20><form action="aendern.php" method="POST">
 <input type="hidden" name="loeschen" value="Löschen">
 <input type="hidden" name="form" value="">
 <input type="Submit" name="aendern" value="Löschen" class="formular_transp">
 </td>
</tr> </form>

wie kann ich nun den zweiten button drücken??

danke schonmal

Moderiert von user profile iconChristian S.: Code-Tags hinzugefügt.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 22.11.04 14:28 
also hast du das in ner TWebbrowser kompo oder in einem offenen Internet Expolorer fenter oder Mozilla oder willste das überhaupt ganz anders amchen.
n bisschen mehr infos bitte !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
CodeRed Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 2000
D7 Pers
BeitragVerfasst: Mo 22.11.04 16:09 
oh, sorry, das hab ich vergessen. das geht über TWebbrowser.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 22.11.04 16:11 

_________________
In the beginning was the word.
And the word was content-type: text/plain.
CodeRed Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 2000
D7 Pers
BeitragVerfasst: Di 23.11.04 21:08 
ok, funktioniert!!! danke schön =)

dann hätte ich nochmal ne kleine frage:
kann ich irgendwie sagen, dass er ne andere funktion ausführen soll, wenn das formular nicht vorhanden ist, da er sich im moment noch aufhängt...
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 24.11.04 15:59 
such mal ein bisschen in der kompo rum, ansonsten musst du den HTML Code der seite parsen, obs ein formular gibt oder nicht

_________________
In the beginning was the word.
And the word was content-type: text/plain.
CodeRed Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 2000
D7 Pers
BeitragVerfasst: Do 24.03.05 11:00 
Ok, hab alle Probleme gelöst
Hier nochmal schnell alles als Zusammenfassung:

Wenn nur ein Formular/Button auf der Seite ist, dann kann man es so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
Webbrowser1.Oleobject.Document.all.action.value := ...;  //Name des Buttons zum bestätigen
Webbrowser1.Oleobject.Document.all.email.value := ...; // Inhalt des Feldes email
Webbrowser1.Oleobject.Document.all.name.value := ...; // Inhalt des Feldes Name
Webbrowser1.Oleobject.Document.all.Login.click;  //Abschicken

Die Namen der Felder bekommt man aus dem Quelltext der Seite

Sollten es jedoch mehrere Buttons sein, dann muss man es so machen:
ausblenden Delphi-Quelltext
1:
Webbrowser1.OleObject.document.forms.item(Nummer,0).submit;					

Wobei man für Nummer die Nummer des Buttons einsetzen muss (bei 0 zu zählen beginnen!)

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Lesco
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 42



BeitragVerfasst: Do 24.03.05 19:30 
das geht auch ohne die webbrowser kompo und zwar damit:

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:
procedure PostToHost(cnt: Integer; host,referer,path,data: string; Owner: Component );
var
  sock: TIdTCPClient;
  i: Integer;
  
begin

  for i:=1 to cnt do
  begin
    
    sock := TIdTCPClient.Create(Owner);
    sock.CreateIOHandler;
    sock.Host := host;
    sock.Port := 80;
    sock.Connect;
    with sock.IOHandler do
    begin
      
      Writeln('POST '+path+' HTTP/1.1');
      Writeln('Host: '+host);
      WriteLn('Referer: '+referer);
      Writeln('Content-type: application/x-www-form-urlencoded');
      Writeln('Content-length: '+(data.Length).toString);
      Writeln('Connection: close');
      Writeln('');
      Writeln(data);
    end;
    sock.Disconnect;
    sock.Free;
  end;
 
end;


is ursprünglich php-code gewesen hab den nach Delphi übersetzt
Quelle: faq-php.de/q/q-code-post.html