$user = $dbh->quote( $user ); my ( $field, $sub_parent ) = $parent eq 'Father' ? ( 'Father', "'Mother'" ) : ( 'Mother', "'Father'" ); $sth = $dbh->prepare ("select $field from Roster where User = $user"); $sth->execute (); my $name = $sth->fetchrow_array; if ($name eq ""){ $sth = $dbh->prepare ("select $sub_parent from Roster where User = $user"); $sth->execute (); $name = $sth->fetchrow_array; } #end chk for not parent if statement. print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name"); $sth = $dbh->prepare ("select distinct Volunteer from Volunteer where Volunteer = ? and Date = ?"); foreach my $date ( @volunteer_date ) { $sth->execute ( $name, $date ); my $chk = $sth->fetchrow_array; if ($chk eq $name) { print $query->h1({-align=>'center'}, "You are already signed up for this date: $date"); } #end if statement else { $sth = $dbh->prepare ("select max(Number) from Volunteer where Date = ? and Volunteer = 'TBD'"); $sth->execute ($date );