delphi如何提交表单,有几种方法,能否举个实例!!
希望大家踊跃回答如果感觉很详细很明白的话我就把分给他!!!感觉好会多加分!我主要是用来自动登录论坛或者网站使用,主要是能把用户名和密码提交上去然后登陆!!!TIdAuth...
希望大家踊跃回答 如果感觉很详细 很明白的话 我就把分给他!!!
感觉好会多加分!
我主要是用来自动登录论坛或者网站使用,主要是能把用户名和密码提交上去然后登陆!!!
TIdAuthentication这个是什么 ?delphi提示报错!!我再调试看!!! 展开
感觉好会多加分!
我主要是用来自动登录论坛或者网站使用,主要是能把用户名和密码提交上去然后登陆!!!
TIdAuthentication这个是什么 ?delphi提示报错!!我再调试看!!! 展开
展开全部
Delphi Indy控件实现网络验证与asp通信2009-04-21 17:18unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, ComCtrls, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
state: TStatusBar;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
Label2: TLabel;
Edit2: TEdit;
Button2: TButton;
Label3: TLabel;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
name:String;
password:string;
GetURL :String;
PostURL :String;
GetHtml :String;
sParams :String;
aParams :TStrings;
aStream :TStringStream;
begin
IdHTTP1 := TIdHTTP.Create(nil);
aParams := TStringList.Create;
aStream := TStringStream.Create('');
memo1.Lines.Clear ;
name:=edit1.Text ;
password:=edit2.Text ;
GetURL := 'http://localhost/getinfo.asp'; {登录页面网址}
PostURL := 'http://localhost/getinfo.asp?password='+password; {提交网址}
sParams := 'name='+name; {提交参数}
try
aParams.Clear;
aParams.Add(sParams);
GetHtml := IdHTTP1.Get(GetURL); {取登录页面}
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(PostURL, aParams, aStream); {提交}
memo1.lines.Add(aStream.DataString);
memo1.SelectAll ;
finally
IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close();
end;
end.
-----------------------------------------------------GetInfo.asp----------------------------------------
<%@LANGUAGE = VBScript.Encode%>
<!--#include file="conn.asp"-->
<%
dim rs,sql,username,regcode,active,password,founderr,msg
username=trim(request("name"))
password=trim(request("password"))
if username="" then
founderr=true
msg="username参数无效!"
else
founderr=false
end if
if password="" then
founderr=true
msg="password参数无效!"
else
founderr=false
end if
if founderr=true then
response.write msg
else
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from reguser where username='"&username&"' and password='"&password&"'"
rs.open sql,conn,1,1
if rs.recordcount>0 then
if trim(rs("regcode"))<>"" then
response.write rs("regcode")
else
response.write "返回的用户注册码无效!"
end if
else
response.write "输入的用户名不存在或者密码无效!"
end if
rs.close
set rs=nothing
end if
call closeconn()
%>
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, ComCtrls, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
state: TStatusBar;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
Label2: TLabel;
Edit2: TEdit;
Button2: TButton;
Label3: TLabel;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
name:String;
password:string;
GetURL :String;
PostURL :String;
GetHtml :String;
sParams :String;
aParams :TStrings;
aStream :TStringStream;
begin
IdHTTP1 := TIdHTTP.Create(nil);
aParams := TStringList.Create;
aStream := TStringStream.Create('');
memo1.Lines.Clear ;
name:=edit1.Text ;
password:=edit2.Text ;
GetURL := 'http://localhost/getinfo.asp'; {登录页面网址}
PostURL := 'http://localhost/getinfo.asp?password='+password; {提交网址}
sParams := 'name='+name; {提交参数}
try
aParams.Clear;
aParams.Add(sParams);
GetHtml := IdHTTP1.Get(GetURL); {取登录页面}
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Post(PostURL, aParams, aStream); {提交}
memo1.lines.Add(aStream.DataString);
memo1.SelectAll ;
finally
IdHTTP1.Free;
aParams.Free;
aStream.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close();
end;
end.
-----------------------------------------------------GetInfo.asp----------------------------------------
<%@LANGUAGE = VBScript.Encode%>
<!--#include file="conn.asp"-->
<%
dim rs,sql,username,regcode,active,password,founderr,msg
username=trim(request("name"))
password=trim(request("password"))
if username="" then
founderr=true
msg="username参数无效!"
else
founderr=false
end if
if password="" then
founderr=true
msg="password参数无效!"
else
founderr=false
end if
if founderr=true then
response.write msg
else
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from reguser where username='"&username&"' and password='"&password&"'"
rs.open sql,conn,1,1
if rs.recordcount>0 then
if trim(rs("regcode"))<>"" then
response.write rs("regcode")
else
response.write "返回的用户注册码无效!"
end if
else
response.write "输入的用户名不存在或者密码无效!"
end if
rs.close
set rs=nothing
end if
call closeconn()
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询