?
Solved

getting data

Posted on 1998-01-31
9
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 300 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
PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

 
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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
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…
Suggested Courses

770 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