horakova 0 Newbie Poster

This is actually a CGI 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 pas 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>
<link rel = "stylesheet" type = "text/css" href = "utr.css"/>
</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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.