Solved

getting data

Posted on 1998-01-31
9
180 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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