You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Arnie & Georgia Stender <aa...@bigriver.net> on 2005/12/29 18:22:13 UTC

[users@httpd] Newbe needs help passing form data

Hello,
    I am setting up my own Internet presence starting with DNS and HTML 
servers. I am teaching myself (as much as possible) how to write HTML 
from scratch. Below you will find the server $ENV variables which will 
describe versions of the server etc. This is running on Linux (LFS) 6.0 
server.  I have looked through at least the archives for this month and 
not found an answer to my problem as well as a number of books on the 
subject of writing CGI (perl). So I ask you:
I have written a small HTML with a three field form that is supposed to 
pass the data to a perl script which in turn writes a dynamic HTML page 
based on the input to the form and sends it back to the browser. 
According to all I have read if I use method==POST the form data is 
supposed to be sent to the script via STDIN and if I use method==GET the 
data is sent via the $ENV{QUERY_STRING} variable. When using POST the 
amount of data being sent is available in the $ENV{CONTENT_LENGTH} 
variable. I have enabled everything I can find to run CGI on the server 
but I can not get the server to send any information to the script. I 
created the perl script from the online Apache manual to dump all the 
variables it is passing and the QUERY_STRING is empty and if the form is 
using POST the CONTENT_LENGTH==0. I am about 90% certain that I am 
missing something in the configuration file but after days of looking 
and reading I have not found out what it is. Running 'perl -w script' 
with a QUERY_STRING environment variable set equal to good data produces 
a good looking HTML output so I will go out on a limb and say the 
problem is not in the perl script. So, can anybody tell me what I am 
missing? BTW, the CGI script does produce the static portion of the HTML 
so the script is running just not getting the form data. Thanks in 
advance for any help you can give to point me in the right direction. 
Below is a sanitized output from the Apache ENV dump script.

Arnie

SCRIPT_NAME --> /cgi-bin/env.pl
SERVER_NAME --> stender4.local
HTTP_REFERER --> http://stender4.local/arnie.html
SERVER_ADMIN --> aags777@bigriver.net
HTTP_ACCEPT_ENCODING --> gzip,deflate
HTTP_CONNECTION --> keep-alive
REQUEST_METHOD --> POST
CONTENT_LENGTH --> 0
HTTP_ACCEPT --> 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
SCRIPT_FILENAME --> /usr/local/apache2/cgi-bin/env.pl
SERVER_SOFTWARE --> Apache/2.0.54 (Unix)
HTTP_ACCEPT_CHARSET --> ISO-8859-1,utf-8;q=0.7,*;q=0.7
QUERY_STRING -->
REMOTE_PORT --> 34615
HTTP_USER_AGENT --> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) 
Gecko/20050416 Fedora/1.0.3-1.3.1 Firefox/1.0.3
SERVER_PORT --> 80
SERVER_SIGNATURE -->
Apache/2.0.54 (Unix) Server at stender4.local Port 80

HTTP_ACCEPT_LANGUAGE --> en-us,en;q=0.5
REMOTE_ADDR --> 192.168.77.221
HTTP_KEEP_ALIVE --> 300
CONTENT_TYPE --> application/x-www-form-urlencoded
SERVER_PROTOCOL --> HTTP/1.1
PATH --> /bin:/usr/bin:/sbin:/usr/sbin
REQUEST_URI --> /cgi-bin/env.pl
GATEWAY_INTERFACE --> CGI/1.1
SERVER_ADDR --> 192.168.77.224
DOCUMENT_ROOT --> /usr/local/apache2/htdocs
HTTP_HOST --> stender4.local


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Newbe needs help passing form data

Posted by Sean Davis <sd...@mail.nih.gov>.


On 12/29/05 12:22 PM, "Arnie & Georgia Stender" <aa...@bigriver.net>
wrote:

> Hello,
>     I am setting up my own Internet presence starting with DNS and HTML
> servers. I am teaching myself (as much as possible) how to write HTML
> from scratch. Below you will find the server $ENV variables which will
> describe versions of the server etc. This is running on Linux (LFS) 6.0
> server.  I have looked through at least the archives for this month and
> not found an answer to my problem as well as a number of books on the
> subject of writing CGI (perl). So I ask you:
> I have written a small HTML with a three field form that is supposed to
> pass the data to a perl script which in turn writes a dynamic HTML page
> based on the input to the form and sends it back to the browser.
> According to all I have read if I use method==POST the form data is
> supposed to be sent to the script via STDIN and if I use method==GET the
> data is sent via the $ENV{QUERY_STRING} variable. When using POST the
> amount of data being sent is available in the $ENV{CONTENT_LENGTH}
> variable. I have enabled everything I can find to run CGI on the server
> but I can not get the server to send any information to the script. I
> created the perl script from the online Apache manual to dump all the
> variables it is passing and the QUERY_STRING is empty and if the form is
> using POST the CONTENT_LENGTH==0. I am about 90% certain that I am
> missing something in the configuration file but after days of looking
> and reading I have not found out what it is. Running 'perl -w script'
> with a QUERY_STRING environment variable set equal to good data produces
> a good looking HTML output so I will go out on a limb and say the
> problem is not in the perl script. So, can anybody tell me what I am
> missing? BTW, the CGI script does produce the static portion of the HTML
> so the script is running just not getting the form data. Thanks in
> advance for any help you can give to point me in the right direction.
> Below is a sanitized output from the Apache ENV dump script.

You needn't parse environment variables and the like.  Use CGI.pm.  Here are
the docs and there are MANY sources of examples and online tutorials.

http://search.cpan.org/~lds/CGI.pm-3.15/CGI.pm

There is an example script in the Synopsis that you should be able to use as
a test.  Google is very useful as is perlmonks (http://perlmonks.org).

Sean




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org