procedure TwmMain.wmMainLoginAction(Sender: TObject; Request: TWebRequest;
Response: TWebResponse; var Handled: Boolean);
Var
CookiesList:TStringList;
ErrMsg:String;
begin
Try
CookiesList:=TStringList.Create ;
With CookiesList do
begin
Add('Name='+self.Request.ContentFields.Values['txtLoginName']);
Add('PWD='+self.Request.ContentFields.Values['txtPWD']);
end;
self.Response.SetCookieField(CookiesList,'','',Now+1,False);
finally
CookiesList.Free ;
end;
with self.qryUeser do
begin
if Active then
Close;
SQL.Clear ;
sqlStr:='Select * from User Where UserName='''+self.Request.CookieFields.Values['Name']+'''';
SQL.Add(sqlStr);
Prepare ;
Open;
if IsEmpty then
begin
ErrMsg:='<p align="center"><font size="4" face="Arial">Can not found the user: <font color="#FF0000">';
ErrMsg:=ErrMsg+self.Request.CookieFields.Values['Name']+'</font></font></p>';
ErrMsg:=ErrMsg+'<p align="center"><font size="4" face="Arial"><a href="javaScript:history.go(-1)">Return</a></font></p>';
self.Response.Content:=ErrMsg;
end
else
begin
if FieldByName('Password').AsString=self.Request.CookieFields.Values['PWD'] then
begin
self.Response.Content :=self.pgBrwLv.Content ;
end
else
begin
ErrMsg:='<p align="center"><font size="4" face="Arial">The user: <font color="#FF0000">';
ErrMsg:=ErrMsg+self.Request.CookieFields.Values['Name']+'</font> password incorrect!</font></p>';
ErrMsg:=ErrMsg+'<p align="center"><font size="4" face="Arial"><a href="javaScript:history.go(-1)">Return</a></font></p>';
self.Response.Content:=ErrMsg;
end;
end;
end;
end;
我自己写的CGI
你自己看吧