如何使用delphi在Web上提交表单

时间:2018-05-26 18:26:07

标签: html delphi

如何创建和发布表单,如下面的表格 使用Delphi7

AttributeError: 'A' object has no attribute 'moo' -> Cannot recover attribute 'moo' -> Cannot recover attribute 'F' -> Cannot recover attribute 'G'

1 个答案:

答案 0 :(得分:3)

Delphi预装了Indy(尽管Delphi 7很老,所以考虑upgrading its Indy to a modern version),它有一个Post()组件。它的Params := TStringList.Create; try Params.Add('TestName=...'); IdHTTP1.Request.Username := ...; IdHTTP1.Request.Password := ...; // set other properties as needed... IdHTTP1.Post('http://www.TestAddress.com/TestPage.php', Params); finally Params.Free; end; 方法有重载版本,用于提交网页表单,例如:

Referer

根据服务器的要求,您可能必须首先请求webform的HTML以获取与其关联的任何cookie,以便它们可以作为webform提交的一部分发送回服务器。或者,如果正在提交的网络表单,您可能需要将// make sure TIdHTTP.AllowCookies is set to True beforehand... IdHTTP1.Get('http://www.TestAddress.com/WebForm.php'); Params := TStringList.Create; try Params.Add('TestName=...'); IdHTTP1.Request.Username := ...; IdHTTP1.Request.Password := ...; // set other properties as needed... IdHTTP1.Request.Referer := 'http://www.TestAddress.com/WebForm.php'; IdHTTP1.Post('http://www.TestAddress.com/TestPage.php', Params); finally Params.Free; end; 请求标头设置为URL:

<tr>