<%init> use DBI; # Process submitted data. my $a=$ARGS{st_def_id}; my $b=$ARGS{new_sc}; my $info=$ARGS{new_info}; our $dbh=$m->comp('mysql-connect-st.mas'); my $result; if($ARGS{add_sc} eq "Add SC"){ if (($a ne "") && ($b ne "")) { # Insert a new database record. my $sql="insert into st_success_conditions (st_def_id, success_condition, information) values ('$a','$b', '$info')"; my $sth=$dbh->prepare($sql); $result=$sth->execute(); } if ($result) { my $redirect="add-st-success-condition.html?id=$a"; $m->redirect($redirect); } else { $m->redirect("database-operation-failure.html"); } } elsif($ARGS{del_sc} eq "Delete SC(s)"){ # Process checkboxes my $c=$ARGS{sc_id}; # Array reference. my @array=(); # If only one item is returned, then force it into an array. if(!($c=~/ARRAY/)){ # it's a scalar push(@array,$c); $c=\@array; } if(($c ne "")) { # Update the deleted flag for the given records. foreach my $x (@{$c}){ my $sql="update st_success_conditions set deleted=1 where id=?"; my $sth=$dbh->prepare($sql); $result=$sth->execute($x); } } if ($result) { my $redirect="add-st-success-condition.html?id=$a"; $m->redirect($redirect); } else { $m->redirect("database-operation-failure.html"); } } else { $m->redirect("debug-page.html"); # $m->redirect("invalid-operation.html"); }