J
John Smith
I hope I am not posting this to the wrong group, as it deals with HTML and
PERL.
I had a script that read information from the QUERY_STRING environment
variable, such as:
$temp=$ENV{'QUERY_STRING'};
It received this information from an HTML document that used the GET method
to send its form data to the perl script, such as:
<FORM method="get" action="/cgi-bin/script.pl">
This worked fine, but the form data ends up as part of the URL, such as:
http://domainname/cgi-bin/script.pl?year=2003&pwd=12345
This would not be too bad except that part of the information sent to the
perl script is a password.
I would prefer that this information not be part of the URL.
As it turns out, an HTML document can also use the POST method to send its
form data to a perl script, such as:
<FORM method="post" action="/cgi-bin/script.pl">
Using this method, the data is apparently sent via the STDIN.
From what I can find on the Internet, a perl script would read this info
something like this:
read(STDIN, $temp, $CONTENT_LENGTH);
When I submit my form data from the HTML document using the POST method, the
CONTENT_LENGTH environment variable does reflect the amount of information I
am sending, but the read statement doesn't store that data to the $temp
variable, the $temp variable is just empty.
Here is a look at part of my script.
#!/usr/bin/perl
use CGI qwstandard);
my $query = new CGI;
print"Content-type: text/html\n\n";
$cl=$ENV{'CONTENT_LENGTH'};
if ($cl > 0)
{
read(STDIN, $temp, $cl); # Read POST data from STDIN
print" 11.. temp = $temp <br>\n";
}
else
{
$temp=$ENV{'QUERY_STRING'}; # Get info submitted from
HTML form
print" 12.. temp = $temp <br>\n";
}
The script will print the following
11.. temp=
The server belongs to my ISP.
It's a Linux server with apache (I guess the Apache is for the Perl to work
or something).
PERL.
I had a script that read information from the QUERY_STRING environment
variable, such as:
$temp=$ENV{'QUERY_STRING'};
It received this information from an HTML document that used the GET method
to send its form data to the perl script, such as:
<FORM method="get" action="/cgi-bin/script.pl">
This worked fine, but the form data ends up as part of the URL, such as:
http://domainname/cgi-bin/script.pl?year=2003&pwd=12345
This would not be too bad except that part of the information sent to the
perl script is a password.
I would prefer that this information not be part of the URL.
As it turns out, an HTML document can also use the POST method to send its
form data to a perl script, such as:
<FORM method="post" action="/cgi-bin/script.pl">
Using this method, the data is apparently sent via the STDIN.
From what I can find on the Internet, a perl script would read this info
something like this:
read(STDIN, $temp, $CONTENT_LENGTH);
When I submit my form data from the HTML document using the POST method, the
CONTENT_LENGTH environment variable does reflect the amount of information I
am sending, but the read statement doesn't store that data to the $temp
variable, the $temp variable is just empty.
Here is a look at part of my script.
#!/usr/bin/perl
use CGI qwstandard);
my $query = new CGI;
print"Content-type: text/html\n\n";
$cl=$ENV{'CONTENT_LENGTH'};
if ($cl > 0)
{
read(STDIN, $temp, $cl); # Read POST data from STDIN
print" 11.. temp = $temp <br>\n";
}
else
{
$temp=$ENV{'QUERY_STRING'}; # Get info submitted from
HTML form
print" 12.. temp = $temp <br>\n";
}
The script will print the following
11.. temp=
The server belongs to my ISP.
It's a Linux server with apache (I guess the Apache is for the Perl to work
or something).