Regarding the proper way to bow, the Gemara (Berakhot 28b) teaches: "R. Tanhum also said in the name of R. Yehoshua b. Levi: In saying Tefillah one should bow down until all the vertebrae in the spinal column are loosened…"
The Gemara only mentions "bowing," which entails, preferably, completely bending the upper body. Sephardic communities, therefore, based on this simple understanding of the Gemara, and the ruling of the Shulchan Arukh (113), don't bend their knees when bowing.
Maran Ha’Shulhan Aruch (Chapter 113) writes: “When one bows, one should bow forward once quickly and when one straightens up, one should do so slowly by straightening one’s head first and then one’s body.”
Ashkenazic communities (see Mishna Berura 113:12), however, customarily bend their knees while saying "barukh," and then bow at "attah," and raise their body before pronouncing God's name. When saying Modim, they bow immediately, without bending their knees.
According to all opinions though, when reciting Hashem’s name, one must be standing erect, as the verse states, “Hashem straightens the bent.” The Rishonim explain this to mean that before one recites the name of Hashem, one must already be standing erect as opposed to straightening up while reciting Hashem’s name.