Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

A simple Delphi CGI application.

Posted on 2001-09-13
5
554 Views
Last Modified: 2013-11-18
Could someone do me a walk-through description of creating a Delphi CGI application that simply accepts a variable (person's name) and creates a HTML page that says hello to that person?

My server-side scripting is okay, and I get how it works, but don't know how to create it in Delphi.  (Just got some web space on an NT server.)

Thanks,

John.
0
Comment
Question by:Jaymol
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6478826
Hello

I prefer to use ISAPI, it's better than CGI and have more benefits more than the CGI

here's a good site for ISAPI Tutorials, it fully made by delphi

http://www.matlus.com/scripts/website.dll

and here's some link for CGI

delphi and CGI
http://www.drbob42.com/books/cgi.htm
http://www.drbob42.com/books/cgi-data.htm


Writing a fancy CGI hit counter in Delphi 5
http://homepages.borland.com/aohlsson/Articles/CounterCGI.html

Web Programming in Delphi
http://www.209software.com/books/wpid/ 

Best regards
Mohammed Nasman
0
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 6479465
Hi John,

1.From File-New select 'Web server app'.
2.From the next menu select 'CGI standalone exe'.
3.You will see a tree WebModule1-Actions. Select 'Actions', right-click on it and select 'Add Item' from the popup menu. WebActionItem1 appears.
4.Select that item and change its 'Default' property to True - this means that that item will be executed on every request.
5.Create an OnAction event handler for that item like the following:

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  UserName : string;
begin
  UserName := Request.QueryFields.Values['name'];
  Response.Content := '<HTML><BODY>Hello ' + UserName + '</BODY></HTML>';
  Response.SendResponse;
  Handled := True;
end;

6.Build the CGI app as 'MyCGI.exe' for example and place it on the server.

7. Calling your app from a html page:
Your html link to call that CGI should look like:

<A HREF="www.hostname.com/path/MyCGI.exe?name=John">Click me</A>

Here 'name' is a query field and 'John' is its value, which value will be passed to your app.

Another way:
If you want to use a html form for calling your app, then 1.Change the WebActionItem1 'MethodType' property from mtAny to mtPost. (optional)
2.In the code above use 'ContentFields' instead of 'QueryFields'.
3.Call the app from a html page like:

<HTML>
<HEAD><TITLE><Test Hello CGI></TITLE></HEAD>
<BODY>
<FORM METHOD=POST ACTION="www.hostname.com/path/MyCGI.exe">
<INPUT TYPE=text NAME="name"  VALUE="">
<INPUT TYPE=submit VALUE="Submit">
</FORM>
</BODY>
</HTML>

Regards, Geo
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6486930
Thanks for your help.

John.
0
 
LVL 17

Expert Comment

by:geobul
ID: 6487069
You are welcome.

Regards, Geo
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6487100
Geo, could you look at the other question I have open?

John.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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)

809 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