foreach $table ( @table_names ) {

	foreach $key (keys %param) {
		unless ($key =~ m/^$table/) {next}
		print STDOUT ("<br>***Debug, key=$key<br>\n") 
			if $debug eq 'yes';
		if ($key =~ m/skill/) {
			$skill = $param{$key};
			$value = $key;
			$value =~ s/.*_skill_(.*)/$1/;
			$table_value = $table . '_' . $value;
			print STDOUT ("<br>***debug, skill=$skill\n",
				" and value=$value<br>\n") 
					if $debug eq 'yes';
			print STDOUT (
				"<br>***debug, table_value=$table_value\n",
				" and value=$value<br>\n") 
					if $debug eq 'yes';
			if (exists $param {$table_value} and 
					defined $param {$table_value} ) {
				$real_value = $param {$table_value};
				
				$ref = $dbh->selectcol_arrayref
					("SHOW COLUMNS FROM $table");
				print STDOUT (
  				 "<p>***debug after call to show columns\n",
  				 "Error string=$DBI::errstr, ",
				 "and error=$DBI::err </p>\n") 
  					if $debug eq 'yes';
				@field_names = @{$ref} if defined $ref;
				print STDOUT (
				 "<p>***Debug, table=$table, field_names=",
				 @field_names,
				 "<br>\n") 
					if $debug eq 'yes';
				unless (defined $ref) {
					&send_message($error, 
                		 "Could not get field names for table $table.",
                		 "Error string=$DBI::errstr, and error=$DBI::err");
					goto END_OF_PROGRAM;
				}
		
				$names_as_string = '';
				$place_holders = '';

				foreach $field_name (@field_names) {
					$names_as_string = $names_as_string . 
							$field_name . ',';
					$place_holders = $place_holders . '?,';
				}

				$names_as_string =~ s/,$//;
				$place_holders =~ s/,$//;

# Slog through all the variables to set up insert.

				$i = 0;

				foreach $field_name (@field_names) {
					if ( $field_name eq 'local_id' ) {
						$all_values[$i] = undef;
					}
					elsif ($field_name eq 'contact_id' ) {
						$all_values[$i] = $contact_id;
					}
					elsif ($field_name =~ m/name$/ ) {
						$all_values[$i] = $real_value;
					}
					elsif ($field_name =~ m/skill/ ) {
						$all_values[$i] = $skill;
					}
					else {
						$all_values[$i] = undef;
					}
					$i++;
				}

# Deal with people submitting comments and other text for possible
# additional options to the table.  Send them as e-mail to the
# administrator.

				if ($other =~ m/\w+/ ) {
					print MAIL (
						"\ttable is $table\n",
						"Comment: $other\n");
					$mail_to_send = 'yes';
				}
	
				print STDOUT ("<p>***Debug, table=$table<br>\n",
				 "names_as_string=$names_as_string<br>\n",
				 "place_holders=$place_holders<br>\n") 
					if $debug eq 'yes';
				$count = 0;
				$sth = $dbh ->prepare 
						("INSERT INTO $table 
						($names_as_string) VALUES
						($place_holders)");
				$count += $sth -> execute((@all_values));
				print STDOUT 
					("***Debug, Error string=$DBI::errstr, ",
					"and error=$DBI::err\n")
						if $debug eq 'yes';	
				if ($count > 0) {
					print STDOUT (
		  		 	"<br>Successfully inserted <b>",
				 	"$real_value</b> data ",
		  		 	"into the <b>$table</b> table.\n");
				}
				
			}
			else {
				print STDOUT ("<br>***debug, param of ",
				  "table_value=$table_value\n",
				  " does not exist.\n<br>")
					if $debug eq 'yes';
				next;
			}
		}
		else {
			next;
		}
	}
	
}
