Hadith regarding the saying of “Allahumma Rabbana laka-l-hamd or Rabbana walaka-l hamd” while in salah
Narrated by Abu Huraira:
Allah’s Apostle said, “When the Imam says, “Sami’ a-l-lahu Liman hamida,” you should say, “Allahumma Rabbana laka-l-hamd.” And if the saying of any one of you coincides with that of the angels, all his past sins will be forgiven.”
(Bukhari, Volume 1, Book 12, Number 762: )
Narrated by ‘Ikrima:
I prayed behind a Sheikh at Mecca and he said twenty two Takbirs (during the prayer). I told Ibn ‘Abbas that he (i.e. that Sheikh) was foolish. Ibn ‘Abbas admonished me and said, “This is the tradition of Abu-l-Qasim.” And narrated Abu Huraira: Whenever Allah’s Apostle stood for the prayer, he said Takbir on starting the prayer and then on bowing. On rising from bowing he said, “Sami’ a-l-lahu liman hamida,” and then while standing straight he used to say, “Rabbana laka-l hamd” (Al-Laith said, “(The Prophet said), ‘Walaka-l-hamd’.” He used to say Takbir on prostrating and on raising his head from prostration; again he would Say Takbir on prostrating and raising his head. He would then do the same in the whole of the prayer till it was completed. On rising from the second Rak’a (after sitting for At-Tahiyyat), he used to say Takbir.
(Bukhari, Volume 1, Book 12, Number 755: )