cgi first time!
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
stocki · 2015-03-26 19:12
Hello, I am cgi beginner! When I do this in firefox
http://localhost/test.cgi?email=xx
I get only "Hello World!"
Where is email=xx ??? Whats wrong here?
Thanks!
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, httpdefs, fpHTTP, fpWeb;
type
{ TFPWebModule1 }
TFPWebModule1 = class(TFPWebModule)
procedure DataModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
FPWebModule1: TFPWebModule1;
implementation
{$R *.lfm}
{ TFPWebModule1 }
procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest:
TRequest;
AResponse: TResponse; var
Handled: Boolean);
begin
AResponse.ContentType := 'text/html;charset=utf-8';
AResponse.Contents.Add(ARequest.Content+'
');
AResponse.Contents.Add(ARequest.ContentFields.Values['email'] +
'
');
AResponse.Contents.Add('Hello World!
');
Handled := True;
end;
initialization
RegisterHTTPModule('TFPWebModule1', TFPWebModule1);
end.
----------------------------------------------------------------------
Leledumbo · 2015-03-27 04:07
ContentFields contain POST data, GET uses different properties
http://wiki.freepascal.org/fcl-web#Reading_GET_data