Are there any chances of a person being reinfected with typhoid at regular intervals again if they don't follow proper medication and diet, even though they are cured or survived the first infection? Can you gain immunity to typhoid?
Reinfection with typhoid fever is certainly possible.
An older human challenge study found that individuals with an induced infection were less likely to develop an infection if they had been previously infected, but 23% of them still developed a clinical fever. Another somewhat old study suggests that unless immunologically boosted, immunity to typhoid fever cannot last for more than ~ 1 year.
Even immunity that arises from vaccination wanes and needs a booster after a few years.
Reinfection, regardless of the success of your treatment or diet, is very possible.