Solved

getting data

Posted on 1998-01-31
9
183 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Register AutoHotkey 12 85
React or Angular? 6 80
Recursively Delete Files 5 94
help with PowerShell script for registry permissions 8 102
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

860 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