unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Label1: TLabel;
lblFlavor: TLabel;
edtFirstName: TEdit;
btnSubmit: TButton;
cmbxFlavor: TComboBox;
WebBrowser1: TWebBrowser;
procedure btnSubmitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses HTTPApp;
{$R *.DFM}
procedure TForm1.btnSubmitClick(Sender: TObject);
var
EncodedDataString: string;
PostData: OleVariant;
Headers: OleVariant;
I: Integer;
begin
// First, create a URL encoded string of the data
EncodedDataString := 'username=' + HTTPEncode(edtFirstName.Text) + '&' +
'password=' + HttpEncode(cmbxFlavor.Text);
// The PostData OleVariant needs to be an array of bytes as large
// as the string (minus the NULL terminator)
PostData := VarArrayCreate([0, Length(EncodedDataString) - 1], varByte);
// Now, move the Ordinal value of the character into the PostData array
for I := 1 to Length(EncodedDataString) do
PostData[I-1] := Ord(EncodedDataString);
Headers := 'Content-Type: application/x-www-form-urlencoded' + #10#13;
// Finally, we just Naviagte to the URL. Note that you may have to modify
// the path to your ASP page's location.
WebBrowser1.Navigate('http://www.xxx.net/login.asp', EmptyParam,
EmptyParam, PostData, Headers);
end;
end.