Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

writing a simple win-cgi script for Delphi

Posted on 1997-08-29
3
Medium Priority
?
262 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 100 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re‚Ķ
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

877 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