Solved

A simple Delphi CGI application.

Posted on 2001-09-13
5
509 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:mnasman
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

13 Experts available now in Live!

Get 1:1 Help Now