You might have attempted to insert or update form data into
the first table, that was meant for the second table. Why don't you
code the names of the form fields with indices, e.g. fieldname_1,
fieldname_2, which immediately tells you which table the data will
go to.