关于网友提出的“ delphi idhttp 向asp 或PHP提交参数的问题”问题疑问,本网通过在网上对“ delphi idhttp 向asp 或PHP提交参数的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: delphi idhttp 向asp 或PHP提交参数的问题
描述: 最近在学DELPHI7时遇到了问题;代码运行无错误,但就是没反应,抓包工具也抓不到数据,关了防活墙,加了ANTIFREE组件也没用,不知什么原因,代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
no1:String;
no2:string;
PostURL :String;
sParams :String;
aParams :TStrings;
aStream :TStringStream;
begin
IdHTTP1 := TIdHTTP.Create(nil);
aParams := TStringList.Create;
aStream := TStringStream.Create('');
no1:='9' ;
no2:='222' ;
PostURL:='http://www.*****.com/factory/vote.aspx?r='+ no1; //提交网址
sParams:= 'uid='+no2; //参数
try
aParams.Clear;
aParams.Add(sParams);
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(PostURL, aParams, aStream); //提交
finally
IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;
end;
end.
以上介绍了“ delphi idhttp 向asp 或PHP提交参数的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2299610.html