hello I am at my wits end. I am having trouble processing multi-select lists and checkboxes then sendind the form data to my sql database. it creates/updates the record fine. however it never post all the data from the checked boxes, uses only one. I am using perl/cgi scripts. Here is 1 sample what I am using. I only included the important parts of the code for each. but no matter how many boxes are checked on one value is returned. I would greated appreciate any solutions
Mike
[html form]
<form action="quest_done.cgi" method="post">
1. What location do you fantasize about for a scene?</B>
</font><br>
<input type=checkbox name=QUESTIONlocation_encounter value=01 > A dungeon<br>
<input type=checkbox name=QUESTIONlocation_encounter value=02 > An old castle<br>
<input type=checkbox name=QUESTIONlocation_encounter value=03 > The beach<br>
<input type=checkbox name=QUESTIONlocation_encounter value=04 > A moving vehicle (i.e. car)<br>
<input type=checkbox name=QUESTIONlocation_encounter value=05 > My bed<br>
<input type=checkbox name=QUESTIONlocation_encounter value=06 > An airplane<br>
<input type=checkbox name=QUESTIONlocation_encounter value=07 > A dark back alley<br>
<input type=checkbox name=QUESTIONlocation_encounter value=08 > A movie theatre<br>
<input type=checkbox name=QUESTIONlocation_encounter value=09 > A funeral home<br>
<input type=checkbox name=QUESTIONlocation_encounter value=10 > A medieval torture chamber<br>
<input type=checkbox name=QUESTIONlocation_encounter value=11 > Under a waterfall<br>
<input type=checkbox name=QUESTIONlocation_encounter value=12 > My desk at work<br>
<input type=checkbox name=QUESTIONlocation_encounter value=13 > Elevator<br>
<input type=checkbox name=QUESTIONlocation_encounter value=14 > A swimming pool or hot tub<br>
<input type=checkbox name=QUESTIONlocation_encounter value=15 > A store dressing room<br>
<input type=checkbox name=QUESTIONlocation_encounter value=16 > The mnamedle of Central Park<br>
<input type=checkbox name=QUESTIONlocation_encounter value=17 > A Church<br>
<input type=checkbox name=QUESTIONlocation_encounter value=18 > Different time period (past or present)<br>
<input type=submit name=submit value=answer>
</form>
[quest_done.cgi]
&form_parse;
$location = $FORM{'QUESTIONlocation_encounter'};
#
use DBI;
$dbh = DBI->connect("dbi:mysql:$mysqldatabase","$mysqlusername","$mysqlpassword") || die("Couldn't connect to database!\n");
print "Content-Type: text/html\n\n";
#
&savedata;
&printconfirmation;
$dbh->disconnect;
#
sub savedata {
$query = "REPLACE INTO Question values('$locations')";
$dbh->do($query);
}
#
sub form_parse {
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair(@pairs){
($name,$value)=split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->/ /g;
$value =~ tr/\\|[|]|<|!|"|$|{|}|*|#|'|>|||;|%/ /;
$FORM{$name} = $value;
}
}
#
Mike
[html form]
<form action="quest_done.cgi" method="post">
1. What location do you fantasize about for a scene?</B>
</font><br>
<input type=checkbox name=QUESTIONlocation_encounter value=01 > A dungeon<br>
<input type=checkbox name=QUESTIONlocation_encounter value=02 > An old castle<br>
<input type=checkbox name=QUESTIONlocation_encounter value=03 > The beach<br>
<input type=checkbox name=QUESTIONlocation_encounter value=04 > A moving vehicle (i.e. car)<br>
<input type=checkbox name=QUESTIONlocation_encounter value=05 > My bed<br>
<input type=checkbox name=QUESTIONlocation_encounter value=06 > An airplane<br>
<input type=checkbox name=QUESTIONlocation_encounter value=07 > A dark back alley<br>
<input type=checkbox name=QUESTIONlocation_encounter value=08 > A movie theatre<br>
<input type=checkbox name=QUESTIONlocation_encounter value=09 > A funeral home<br>
<input type=checkbox name=QUESTIONlocation_encounter value=10 > A medieval torture chamber<br>
<input type=checkbox name=QUESTIONlocation_encounter value=11 > Under a waterfall<br>
<input type=checkbox name=QUESTIONlocation_encounter value=12 > My desk at work<br>
<input type=checkbox name=QUESTIONlocation_encounter value=13 > Elevator<br>
<input type=checkbox name=QUESTIONlocation_encounter value=14 > A swimming pool or hot tub<br>
<input type=checkbox name=QUESTIONlocation_encounter value=15 > A store dressing room<br>
<input type=checkbox name=QUESTIONlocation_encounter value=16 > The mnamedle of Central Park<br>
<input type=checkbox name=QUESTIONlocation_encounter value=17 > A Church<br>
<input type=checkbox name=QUESTIONlocation_encounter value=18 > Different time period (past or present)<br>
<input type=submit name=submit value=answer>
</form>
[quest_done.cgi]
&form_parse;
$location = $FORM{'QUESTIONlocation_encounter'};
#
use DBI;
$dbh = DBI->connect("dbi:mysql:$mysqldatabase","$mysqlusername","$mysqlpassword") || die("Couldn't connect to database!\n");
print "Content-Type: text/html\n\n";
#
&savedata;
&printconfirmation;
$dbh->disconnect;
#
sub savedata {
$query = "REPLACE INTO Question values('$locations')";
$dbh->do($query);
}
#
sub form_parse {
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair(@pairs){
($name,$value)=split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->/ /g;
$value =~ tr/\\|[|]|<|!|"|$|{|}|*|#|'|>|||;|%/ /;
$FORM{$name} = $value;
}
}
#