If, on the trial of the contest of any election, either before the judge of probate or the circuit court, it shall appear that any person other than the one whose election is contested, received or would have received, had the ballots intended for the person and illegally rejected been received, the highest number of legal votes, judgment must be given declaring such person duly elected, and such judgment shall have the force and effect of investing the person thereby declared elected, with full right and title to have and to hold the office to which the person is declared elected. If it appears that two or more persons have, or would have had, if the ballots intended for them and illegally rejected had been received, the highest and equal number of votes for such office, judgment must be entered declaring the fact, and such fact must be certified to the officer having authority to fill vacancies in the office the election to which was contested. If the person whose election is contested is found to be ineligible to the office, judgment must be entered declaring the election void and the fact certified to the appointing power. If the party whose election is contested is found to have been duly and legally elected, judgment must be entered declaring the party entitled to have and to hold the office to which the party was so elected.
Ala. Code § 17-16-59 (1975)