Get CGI Form contain variable and email it

Posted on 1997-06-05
Last Modified: 2010-04-06
I wanna know how to get the number or string on each text area or radio button from form variables. Also how can I send them in simple structured format to my email account.All should created on CGI-BIN Delphi2 with NT 4.0 server only using IIS.YGOLAN already give me guide on how to get environment variable on QUERY_STRING, but I really only get the thingy beside the cgi.exe?xxx=xxx string, but I want to get the strings which we can get from user input when they submit their form.For example I have a query text area asking about user name, and a button for submit it. So what should I do in both HTML and CGI program also how can I send it to my email so I canalerted that user has input their data ??below HTML is what I do now please confirm if there should any change on it :<Form Action="/cgi-bin/cgi.exe" method="post">Your name:<BR><input type="text" name="name"><p><input type="submit" value="ok"></form>Also what I really want received at my email is formated like this below :Name : user_namethats all folks thxx for your attentionI'll appreciate your help.
Question by:anakecil
  • 4
  • 3
  • 2

Expert Comment

ID: 1336831
This isn't a answer to your question, but :
Have you tried ISAPI instead of CGI?


Author Comment

ID: 1336832
Thxx for your comment crb, if I can use ISAPI, I will, but I don't know how since I'm newbies on Delphi and website programming.-AnaKecil -

Expert Comment

ID: 1336833
I am not sure if I'am right but I think the server executes ISAPI's faster and you will get some nice functions :)


Author Comment

ID: 1336834
Yes you right I guess, thought I'm not yet even know about how to program on ISAPI thingy, but I'm sure ISAPI better than CGI since that's why microsoft create it for standard and borland also supported it on Delphi 3. But the thing is my delphi is ver 2.0 so can I still program on ISAPI without any additional thingy, cause I already browse the but I can't get anything ISAPI for my 2.0 version and only for 3.0 available.Also rather than just comment please answer my question if you can my friend :) thxx you very much for your attention.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline


Accepted Solution

ygolan earned 50 total points
ID: 1336835
How you retrieve the variable from the form depends on what you specified in the METHOD parameter of the form. If you use "GET", the variables will be encoded on the query string and you can access them as I described before. For example, the following HTML (based on the one you gave) :

<Form Action="/cgi-bin/cgi.exe"
method="get"> Your name:<BR><input type="text" name="name"><p> <input type="submit" value="ok"> </form>

Will produce the following query string, assuming the value in the name field is "ygolan" :


If you use POST instead of GET (<form ... action="post">), reading the values is more complicated, since they are sent in the input stream (stdin) instead of QUERY_STRING. Unless you are sending large (> 1024 bytes) amounts of data, there is no need for you to get into this. However, if you need to do that, just read the data from the stdin - it is in the same format as the query string. The amount of data you should read is specified by the CONTENT_LENGTH environment variable.

Sending the submitted data by mail is a whole different question :-)

I really suggest that you consider using a 3rd party product instead of trying to do it all yourself. There are some pretty good products out there for Delphi 2 and Delphi 3 - I know because I wrote one of them :-)

Author Comment

ID: 1336836
Wow okie I sought to try your answer ASAP :)But can you tell me how to create simple"HELLO WORLD" like at CGI in ISAPI usesDelphi 2.0 without any additional thingy component ??nice thxxx you answer excellent - AnaKecil -

Expert Comment

ID: 1336837
Library project1;

Uses Classes, SysUtils, Windows, ISAPI;

Function GetExtensionVersion (var pVer : THSE_VERSION_INFO) : BOOL; export; stdcall;
  StrPCopy(pVer.lpszExtensionDesc, 'Hello World Sample DLL');
  result := true;

Function HttpExtensionProc (var pECB : TEXTENSION_CONTROL_BLOCK) : DWORD; export; stdcall;
  HelloMsg : string = 'Hello World';
  Size: dword;
  DataType: dword;
  pECB.ServerSupportFunction( pECB.ConnID,

  Size := Length(HelloMsg);
  pECB.WriteClient( pECB.ConnID, PChar(HelloMsg), Size, 0 );


Author Comment

ID: 1336838
Thxx so much :) I'll try that one for my first ISAPI app. Anyway could you give me description on your email send program ? so I may think about to buy that component :) also tell me can I pay you via VISA CARD ??okie you always excellent- AnaKecil -

Expert Comment

ID: 1336839
What I've developed is not a email send component. Instead, it's a framework for developing Web applications using Delphi. It's called WebApp, and you download a preview version from

If you need more information, contact me through


Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

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

14 Experts available now in Live!

Get 1:1 Help Now