Solved

getting data

Posted on 1998-01-31
9
184 Views
Last Modified: 2013-12-25
im not sure that CGI is the right solution. what i wanna do is to put a form to my web-site where the user can fill in data like eMail and some information about himself. But i have no idea how that is done.
0
Comment
Question by:omsec
  • 5
  • 4
9 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1831889
Yes, CGI is one way to do this.  It's also the most common way.  If you make a form that looks like this:

<form action="http://myserver.company.com/cgi-bin/cgi-program" method=GET>
<input type=text name=test>
<input type=submit name=submit value=submit>
</form>

When you click the submit button, the browser will send a command back to the server which looks like:

http://myserver.company.com/cgi-bin/cgi-program?test=Some+text+here

When this gets back to your server, it will run the program cgi-program and set the environment string QUERY_STRING to the value text=Some+text+here.  In C you can get this with the getenv() function (other languages will vary).  You need to respond back to the client browser.  A minimal response would be:

printf("Content-type: text/html\n\n");
printf("<HTML>\n");
printf("Thanks...\n");
printf("</HTML>\n");
0
 
LVL 2

Author Comment

by:omsec
ID: 1831890
you mean, this is kinda a "link" to a sub-program ? I havent really experience in C/C++, but i know the GetEnv - Function from Pascal and i know what it does. So how will i need to write that program that should store the data ?

0
 
LVL 32

Expert Comment

by:jhance
ID: 1831891
You need to write a program to read and/or store the data that comes back from a form.  Depending on your server environment, you might do that in PERL, C, C++, unix shell, Java, even Pascal.
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 32

Expert Comment

by:jhance
ID: 1831892
By the way, it's not a link to a subprogram.  The web server actually invokes your cgi-bin program.  It sets some environment variables (like QUERY_STRING) and also attaches your program's output stream, through itself, back to the client web browser.  Your cgi-bin program must send a valid response back to the browser or the whole thing will just sit there.

Here is an example cgi-bin script written in unix bourne shell.  It just receives the cgi-bin request and echos out most (if not all) of the environment variable information:

#!/bin/sh

echo Content-type: text/plain
echo

echo CGI/1.0 test script report:
echo

echo argc is $#. argv is "$*".
echo

echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
echo PATH_INFO = "$PATH_INFO"
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
echo SCRIPT_NAME = "$SCRIPT_NAME"
echo QUERY_STRING = "$QUERY_STRING"
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH
0
 
LVL 2

Author Comment

by:omsec
ID: 1831893
i dont have an unix compiler. only an old crappy C/C++ borlad c 3.1
0
 
LVL 32

Expert Comment

by:jhance
ID: 1831894
Like I said, what language you use depends on the web server you are using.  What is your web server environment?
0
 
LVL 2

Author Comment

by:omsec
ID: 1831895
oh, emm.. unix

www.centralnet.ch its at my ISPs server
0
 
LVL 32

Expert Comment

by:jhance
ID: 1831896
then you should be able to use any language that is supported on that server.  The above example is in Bourne Shell and doesn't even need to be compiled.
0
 
LVL 2

Author Comment

by:omsec
ID: 1831897
ok, thanx and by the yer very fast :)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

749 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