Program ExCGI1; Uses SysUtils, GenSuppt, WebSBTL; const idAccountSignUpForm = 4321; ModuleName = '/scripts/tcgi.dll'; txtUserName = 'txtUserName'; txtAddress = 'txtAddress'; txtCity = 'txtCity'; txtState = 'txtState'; txtAcctType = 'txtAcctType'; txtSubmit = 'Submit'; const AcctTypes : Array [1..3] of String = ('Novice', 'Intermediate', 'Master'); function HTTPExtensionProc : Cardinal; var HTTPConn : TWinCGI; function AccountTypeVal(strAcctType : String) : Byte; begin result := 1; if strAcctType = AcctTypes[2] then result := 2 else if strAcctType = AcctTypes[3] then result := 3; end; procedure FormSignUp; begin With HTTPConn do begin Send ('<blockquote>'); CenterOn; FormBegin (idAccountSignUpForm, POST, ModuleName, URL_DEFAULT); Send ('User Name: '); TextField(txtUserName, iif(GetFormVar(txtUserName, False) <> '' , GetFormVar(txtUserName, False), 'John Smith'), 20, 30); Send (' Address: '); TextField(txtAddress, iif(GetFormVar(txtAddress, False) <> '' , GetFormVar(txtAddress,False), '1406 Stemmons Pkwy'), 20, 35); Send ('<p>City: '); PullDownListBegin(txtCity); PullDownListAdd('Chicago', '0', GetFormVar(txtCity, False) = '0'); PullDownListAdd('Dallas', '1', GetFormVar(txtCity, False)='1'); PullDownListAdd('New York', '2', GetFormVar(txtCity, False)='2'); PullDownListAdd('Seattle', '3', GetFormVar(txtCity, False)='3'); PullDownListEnd; Send (' State: '); TextField(txtState, iif(Length(GetFormVar(txtState, False)) > 0 , GetFormVar(txtState, False), 'TX'), 2, 2); Send (' Account Type: '); ListBox(txtAcctType, AcctTypes, AccountTypeVal(GetFormVar(txtAcctType, False))); NewPara; CenterOff; SubmitButton(txtSubmit, txtSubmit); FormEnd; Send ('</blockquote>'); end; end; begin HTTPConn := TWinCGI.Create; With HTTPConn do begin HTTPHeader; HTMLBegin ('Account Signup Form', '', ''); CustomBodyBegin('', '#000000', '#FFFFFF', '', '', ''); Case RequestMethod of GET : begin if QueryCount = 0 then begin Header(2, 'Please fill out the account form', true); FormSignUp end else ShowBadRequest(''); end; POST : begin Case FormID of idAccountSignUpForm : begin Header(2, 'Thank you for filling out the form... Do it again!', true); FormSignUp; end; else ShowBadRequest(''); end; end; end; end; HTTPConn.Free; result := 0; end; begin HTTPExtensionProc; end.
©1996 by Stephen Genusa. All rights reserved.