Solved

writing a simple win-cgi script for Delphi

Posted on 1997-08-29
3
242 Views
Last Modified: 2013-11-18
I have created an HTML form with 3 text boxes.  I want to submit these inputed values to a win-cgi program that will take the name value pair and show the user what he entered.

My OS is win 95 and I am running MS Personal Web Server 1.0a

Thanks
0
Comment
Question by:scottwatson
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
itamar earned 50 total points
ID: 1342993
You might want to start with this site.  It contains some good information on starting basic for developing a CGI applicaiton...

http://www.borland.com/delphi/news/cobb/ddj1_6b/ddj1_6b.html

or, you can check the code below (from Erik Johnson):

PROGRAM Hello;

//Credits to Erik Johnson (erik@phidias.colorado.edu)

USES Windows, SysUtils;

FUNCTION GetEnvVar( KeyStr : STRING ) : STRING;
 // a routine to simplify accessing environment information
 CONST maxlen = 1024; // whatever the max length you need is
 VAR  buf : ARRAY[0..maxlen] OF Char;
 BEGIN
   IF GetEnvironmentVariable( PChar( KeyStr),Buf,maxlen) > 0 THEN
      Result := StrPas( Buf )
   ELSE
      Result := '';
 END;

BEGIN
   AllocConsole; // or use apptype compiler directive
   writeln('Content-type: text/html'); // required html header
   writeln(''); //required html header

   // you can now Writeln & Write whatever html you want...
   Writeln( '<TITLE>hello page</TITLE>' );
   Writeln( '<b>Hello World</b>' );
   Writeln( '<br>' );
   Writeln( 'query='+GetEnvVar('QUERY_STRING' ));
END.

Different webservers supply different environment variables... some
common ones are...
'CONTENT_TYPE','GATEWAY_INTERFACE','HTTP_ACCEPT','',
'QUERY_STRING','REMOTE_ADDR','REMOTE_HOST',
'REMOTE_USER','REQUEST_METHOD','SCRIPT_NAME',
'SERVER_NAME','SERVER_PROTOCOL','SERVER_SOFTWARE','REFERER'

Credits to Erik Johnson (erik@phidias.colorado.edu)
0
 

Author Comment

by:scottwatson
ID: 1342994
Could you explain how the Cobb example works.  I entered the code word for word but my out page ends with ERROR.  I must add that I used a HTML form to try and input the 3 text boxes into the INI file.  Am I supposed to be using the post or get Action Method?  Do I include the location of the 3 files as parameters of my cgi program within my HTML code.
0
 
LVL 4

Expert Comment

by:itamar
ID: 1342995
You must use the POST method.
You don't need to include the location of the 3 files, your Web server will do it for you. That's the way Win-Cgi works.

As if you can check in the code, the program sets the contents of a variable with the string 'ERRO' whenever it doesn't find the ocurrency of a Input Type in the input INI file. Check if you are using exactly the same name of the input types in the ReadString parameters.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question