请帮我看看下面程序有什么问题(TIDHTTP)。。。。。。(50分) (50分)

  • 主题发起人 主题发起人 moonbird
  • 开始时间 开始时间
M

moonbird

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是申请163通行证的delphi程序。可以发送选择的用户名并返回输入个人信息的HTML信息。可以发送个人信息,但是总是返回“提交表单错误”的HTML信息。
代码:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Psock, NMHttp,winsock,idhttp, ExtCtrls;
type
  TForm1 = class(TForm)
    edtusername: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Memo1: TMemo;//用来显示POST后返回的HTML信息
    GroupBox1: TGroupBox;
    edtpassword: TLabeledEdit;
    edtconfirmPassword: TLabeledEdit;
    edtanswer: TLabeledEdit;
    edtemail: TLabeledEdit;
    edtquestion: TLabeledEdit;
    edtfullname: TLabeledEdit;
    edtidCard: TLabeledEdit;
    RadioGroup1: TRadioGroup;
    radmale: TRadioButton;
    Radfemale: TRadioButton;
    GroupBox2: TGroupBox;
    edtyear: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    edtday: TEdit;
    Label4: TLabel;
    GroupBox3: TGroupBox;
    radapplyemailyes: TRadioButton;
    radapplyemailno: TRadioButton;
    edtphone: TLabeledEdit;
    cmbincome: TComboBox;
    Label5: TLabel;
    GroupBox4: TGroupBox;
    Label6: TLabel;
    chkyes2: TCheckBox;
    chkyes3: TCheckBox;
    cmbmonth: TComboBox;
    cmbprovince: TComboBox;
    Label7: TLabel;
    cmbindustry: TComboBox;
    Label8: TLabel;
    cmbdegree: TComboBox;
    Label9: TLabel;
    cmbemployment: TComboBox;
    Label10: TLabel;
    Button2: TButton;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure radapplyemailnoClick(Sender: TObject);
    procedure radapplyemailyesClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  http:TIdHTTP;
  ps:tstrings;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
//按下这个按钮发送选择的用户名
var
        response:TStringStream;
begin
        ps:=tstringlist.Create;
        ps.Clear;
        response:=tstringstream.Create('');
        ps.Add('username='+edtusername.Text);
        try
                http.Request.ContentType:='application/x-www-form-urlencoded';
                http.Post('http://reg4.163.com/Register.jsp',ps,response);
                memo1.Lines.Add(#13#10 + Response.DataString);
                rs.Add(response.DataString);
        finally
                ps.Free;
                response.Free;
        end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
        http:=tidhttp.Create(form1);
        form1.WindowState:=wsMaximized;
end;

procedure TForm1.Button2Click(Sender: TObject);
//按下这个按钮发送个人信息
var
        response:TStringStream;
begin
        if(edtpassword.Text<>edtconfirmpassword.Text)then
        begin
                showmessage('两次输入的密码不同');
                edtpassword.SetFocus;
                exit;
        end;
        ps:=tstringlist.Create;
        ps.Clear;
        response:=tstringstream.Create('');
        ps.Add('&username='+edtusername.Text);
        ps.Add('&password='+edtpassword.Text);
        ps.Add('&question='+edtquestion.Text);
        ps.Add('&confirmPassword='+edtconfirmpassword.Text);
        ps.Add('&answer='+edtanswer.Text);
        ps.Add('&fullname='+edtfullname.Text);
        if (radmale.Checked)then
        begin
                ps.Add('&gender=0');
        end
        else
        begin
                ps.Add('&gender=1');
        end;
        ps.Add('&year='+edtyear.Text);
        ps.Add('&month='+cmbmonth.Text);
        ps.Add('&day='+edtday.Text);
        ps.Add('&idCard='+edtidcard.Text);
        if(radapplyemailyes.Checked)then
        begin
                ps.Add('&ptype=on');
        end
        else
        begin
                ps.Add('&ptype=off');
        end;
        ps.Add('&email='+edtemail.Text);
        ps.Add('&phone='+edtphone.Text);
        ps.Add('&province='+cmbprovince.Text);
        ps.Add('&industry='+cmbindustry.Text);
        ps.Add('&degree='+cmbdegree.Text);
        ps.Add('&employment='+cmbemployment.Text);
        ps.Add('&income='+cmbincome.Text);
        if(chkyes2.Checked)then
        begin
                ps.Add('&yes2=on');
        end
        else
        begin
                ps.Add('&yes2=');
        end;
        if(chkyes3.Checked)then
        begin
                ps.Add('&yes3=on')
        end
        else
        begin
                ps.Add('&yes3=');
        end;   
        try
                http.Request.ContentType:='application/x-www-form-urlencoded';
                //向163提交个人信息
                http.Post('http://reg4.163.com/Register2.jsp',ps,response);
                memo1.Lines.Add(#13#10 + Response.DataString);
        finally
                ps.Free;
                response.Free;
        end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
        http.Destroy;
end;

procedure TForm1.radapplyemailnoClick(Sender: TObject);
begin
        edtemail.EditLabel.Caption:='*电子邮箱';
end;

procedure TForm1.radapplyemailyesClick(Sender: TObject);
begin
        edtemail.EditLabel.Caption:='电子邮箱';
end;

end.
 
会和cookie有关吗?
 
后退
顶部