Solved

writing a simple win-cgi script for Delphi

Posted on 1997-08-29
3
230 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now