develooper Front page | perl.beginners | Postings from October 2009

weird post problem

Thread Next
From:
adlai burman
Date:
October 18, 2009 07:46
Subject:
weird post problem
Message ID:
9C1CBFAA-012F-4BB0-8CC2-00AAD095BDAB@refenestration.com
Hello and help, please.
This is actually a CGI/Perl issue I am having but Perl seems to be the
closest forum here.

I am having a very simple (hence very frustrating) problem with a CGI/
Perl script. For some reason if I pass things from a checkbox they all
get passed fine but the last item is passed twice. I have excised a
paired down script with the html and perl components. I am at wit's
end with this. Please someone tell me what is going on.

 From fill_pg.html:

<HEAD>
<TITLE>Fill pg</TITLE>
</HEAD>
<BODY BGCOLOR=white>

<FORM NAME=fill_pg ACTION="http://10.0.0.139/cgi-bin/fill_pg.pl"
METHOD="post">

<h1>Please select the plants to search<br></h1><br>

<input type=checkbox name=access value=AJ400848>Spinacia oleracea
<input type=checkbox name=access value=DQ020642>Antirrhinum majus
<input type=checkbox name=access value=AJ506156>Amborella trichopoda
<input type=checkbox name=access value=AP000423>Arabidopsis
thaliana<br>
<input type=checkbox name=access value=AP009369>Arabis hirsuta
<input type=checkbox name=access value=AM711640>Cuscuta reflexa
<input type=checkbox name=access value=AJ316582>Atropa belladona
<input type=checkbox name=access value=AP009370>Barbarea verna<br>

<h1>Please select the gene you are looking for:</h1>
<select name=gene>
    <option> petD
    <option> petB
    <option> rpoA
</select>

<CENTER>
<INPUT TYPE="submit" VALUE="SUBMIT">
</CENTER>
</FORM>
</BODY>

Now the Perl script:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
$forminfo = <STDIN>;

@key_value_pairs = split(/&/,$forminfo);
foreach $pair (@key_value_pairs){
     ($key,$value) = split(/=/,$pair);
     $value =~ s/\+/ /g;
     $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
     $FORM_DATA{$key} = $value;
print $FORM_DATA{'access'};
print"<br>";

print $FORM_DATA{'gene'};

}

If I choose, say, the checkboxes corresponding to, say, AJ400848
and AJ316582 and the pulldown list item, say, petD .... this is what I
get:
AJ400848
AJ316582
AJ316582
petD

How do I make it stop doing this? Please help.

AJB



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About