Judgment shall be rendered in favor of the party for whom a majority of the legal votes shall be proven to have been cast, and shall be to the effect that he is entitled to the office in controversy with all the privileges, powers and emoluments belonging thereto and for his costs. If the contestant prevails he shall have judgment placing him in possession of the contested office and for the emoluments thereof from the beginning of the term for which he was elected and for his costs.