Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing html form values

Status
Not open for further replies.

jimmyJIMMYyaya

Programmer
Sep 30, 2001
13
CA
ok i have two fields in my html document
1) txtSearchString
2) cboSearchType

now i want to use $ENV{'QUERRY_STRING'}; to get the values
but what i need to know is how to pass the values on submit ie
<form action=&quot;cgi-bin/search.pl?txtSearchString&cboSearchType&quot; method=&quot;post&quot;>

is there a way
 
#creates input hash from each parameter in param
use CGI qw:)common);
my $cgi=CGI->new();
my %input;

foreach my $p($cgi->param()) {
$input{$p}=$cgi->param($p);
}


This makes the key be whatever the name of each field in the form is. The value for the key is determined by $cgi->param($p). This works for the querystring/method=get as well as for method=post. This of course, is after you set your form and hit submit.

Also try this:

#seperates to keep each field=value...
my @values=split(/&/, $ENV{'QUERY_STRING'});
my $var;
my $val;

#seperates the field=value
foreach my $value (@values)
{
($var, $val) = split /=/, $value;

print $var.&quot; = &quot;.$val.&quot;<br>&quot;;
}


Each one of these works. The first though works for get and post. The second only works for get. Hope this helps. Good luck.

Mike
 
please see faq452-653 which covers some of the basics of CGI.

HTH If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top