These are NOT direct answers but may be of some help:
Unless you have a very specific and well-thought-out reason for using cgi-lib.pl, which is largely obsolete and widely deprecated, use CGI::pm>fixing typo/brain spasm: CGI.pm instead.
Your words and code seem to disagree with each other: I see not 2 tables, but 3: bademails, alerts, and registrations. Am I missing something?
&Conn_to_DB; Undefined subroutine &main::Conn_to_DB ... (As usual, using strict and warn would have let you know about that mistake)