...code a simple win-cgi using wintypes?
Author: Jeffrey Dougall
(*
--- english -------------------------------------------------------------------
How to create a BASIC/MINIMALISTIC WIN CGI program with Delphi.
The code works with LilHTTP web server and any other that supports
WIN CGI's. The calling web page will have to pass two varibles.
The persons name and their email address. The CGI will take the name
and email address from the command line and place it into the HTML
code where apropriate and send the information back to the host.
You can add code to store the information into a database or file
if you wish.
--- german --------------------------------------------------------------------
Diese Methode eignet sich zur Erzeugung von WIN-CGI Module mit minimaler
Anforderungen. Lauffähig unter den gängisten Web-Servern.
eMail-Adresse und Name werden abgefragt und in einer HTML-Antwortseite
zurückgeliefert. Eine Anbindung an einer Datenbank dürfte sich leicht
realisieren lassen.
*)
Uses
wintypes;
procedure TForm1.FormShow(Sender: TObject);
var
c,a,Name,Email:string;
b:integer;
begin
name :='';
email :='';
{ "a" contains the commandline passed by the web server program. }
a:=ParamStr(1);
{ parsing... }
for b:=1 to length(a) do begin
c:=copy(a,b,1);
if (c='&') and (name='') then begin
name:=copy(a,6,b-6);
email:=copy(a,b+7,length(a)-(b+6));
end;
end;
{The following codes sends HTML code to the hosts browser with the
information you want them to see. You need to know HTML coding. }
if (name='') or (email='') then begin
writeln;
writeln('<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
writeln('<meta name="GENERATOR" content="The name of your COMPANY">');
writeln('<title>Untitled Normal Page</title>');
writeln('</head>');
writeln('<body bgcolor="#000080" link="#FFFF00" vlink="#00FFFF" alink="#FFFFFF">');
writeln('<p align="center"><font color="#FFFFFF" size="3" face="Arial"><strong><u>My Home');
writeln('Inc.</u></strong></font></p>');
writeln('<p align="center"><font color="#FFFFFF" size="3" face="Arial">Your');
writeln('request to be placed onto our mailing list has been REJECTED</p>');
writeln('This was due to your details not entered correctly</font></p>');
writeln(' <p align="left"><a href="http://www.my-home.inc"><font');
writeln(' color="#FFFFFF" size="3" face="Arial">[Return To My Home');
writeln(' ]</font></a></p>');
writeln(' <p align="left"><a href="http://www.my-home.inc/mail.htm"><font');
writeln(' color="#FFFFFF" size="3" face="Arial">[Return and try');
writeln(' again]</font></a></p>');
writeln('</blockquote>');
writeln('<p> </p>');
writeln('</body>');
writeln('</html>');
close;
end
Else Begin
writeln;
writeln('<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
writeln('<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">');
writeln('<title>Untitled Normal Page</title>');
writeln('</head>');
writeln('<body bgcolor="#000080" link="#FFFF00" vlink="#00FFFF" alink="#FFFFFF">');
writeln('<p align="center"><font color="#FFFFFF" size="3" face="Arial"><strong><u>My Home');
writeln(' Inc.</u></strong></font></p>');
writeln('<p align="center"><font color="#FFFFFF" size="3" face="Arial">Your');
writeln('request to be placed onto our mailing list has been accepted</font></p>');
writeln('<blockquote>');
writeln(' <p align="left"><font color="#FFFFFF" size="3" face="Arial">Your');
writeln(' Details Are</font></p>');
writeln(' <p align="left"><font color="#FFFFFF" size="3" face="Arial">Name:');
writeln(' '+name+'<br>');
writeln(' Email Address: '+email+'</font></p>');
writeln(' <p align="left"><a href="http://www.my-home.inc"><font');
writeln(' color="#FFFFFF" size="3" face="Arial">[Return To My Home Inc.');
writeln(' ]</font></a></p>');
writeln('</blockquote>');
writeln('<p> </p>');
writeln('</body>');
writeln('</html>');
close;
end;
End;
printed from
www.swissdelphicenter.ch
developers knowledge base