#!/usr/bin/perl
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
push (@qlist, $name);
$qinput{$name} = $value;
}
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Query String</title>\n";
print "</head>\n";
print "<body bgcolor=ffffff>\n";
if (@qlist) {
print "<h1>Query String</h1>\n";
foreach $x (@qlist) {
print "$x=$qinput{$x}<br>\n";
}
}
print "</body>\n";
print "</html>\n";
exit;
To send information to the query string you can change the HTML for standard input so that the form line says this:
<form action=/cgi-bin/query.cgi method=get>
You can also type the URL directly. Try some of the following:
http://localhost/cgi-bin/query.cgi?a=1&b=2&c=3 http://localhost/cgi-bin/query.cgi?search=dog+cat+mouse http://localhost/cgi-bin/query.cgi?text1=apple&text2=banana