A series of polymers containing1,2,4-triazole and tetrazole groups in their main chains were synthesized through several steps. Poly(acryloyl hydrazide) was first prepared and then subjected to a hydrazide reaction with phenyl isothiocyanate to give a 1,2,4-triazole ring (2). This polymer was introduced into a reaction with chloro acetylchloride to yield polymer (3), which was refluxed with sodium azide to give polymer (4). Polymer (5) was synthesized by the reaction of polymer (4) with acrylonitrile in the presence of NH4Cl as a catalyst. Finally, polymer (6) was synthesized by the electrochemical polymerization of polymer (5) using 316L stainless steel as an anti-corrosion coating. Polymer-coated and uncoated stainless steel was tested for corrosion safety in a solution of 0.1 M HCl, followed by Tafel and Potentiostatic procedures at a temperature of 293 K. Nano materials such as ZnO were applied to the monomer solution at different concentrations to enhance the corrosion resistance of the 316L stainless steel surface. The results showed that the performance values of corrosion protection for the polymer coating were increased with the introduction of the nano materials. Furthermore, 13C-NMR, 1H-NMR, and FTIR were recorded to confirm the structures of the poylmers, while their physical properties were tested using atomic force microscope (AFM) and scanning electron microscope (SEM).