Assalaamu alaykum. I have noticed during prayer that my instinctive response when the imam says 'Sami Allaahu liman Hamidah' when rising from the bowing position is to say 'Rabbana wa lana Al-Hamd' instead of 'Rabbana wa laka Al-Hamd'. I am trying to make it my instinct to say the proper reply, but sometimes do not paying attention and then when I go down to prostrate, I forget what I said and whether it was the correct phrase or the incorrect phrase. My question is: should I assume that I said it correctly even though my instinct is to say the wrong term, or should I always assume that I said it properly if I do not know for sure? Also, how does saying the wrong phrase affect the validity of my prayer?
All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
Going through your past questions, it is clear that you experience many obsessive whisperings (Waswaas). Therefore, we advise you to repel and totally disregard such whisperings. You should know that when the person is overwhelmed with excessive doubts (pertaining to acts of worship and ritual purity), he is enjoined to disregard them and refrain from acting upon them. He is not liable for Sujood as-Sahw (prostration of forgetfulness). Al-Mardaawi wrote, "When a person constantly experiences doubts during his prayer to the point that they amount to obsessive whisperings, he should ignore and disregard such doubts because considering and acting upon such doubts result in a kind of obstinacy, and thus he performs more Rak‘ahs (than what he is required to perform) although he is certain that he had completed the correct number of Rak‘ahs, and similar behavior. Therefore, he should totally disregard such doubts." [Al-Insaaf]
Hence, when you have doubts about saying "Rabbana wa lana Al-Hamd" instead of "Rabbana wa laka Al-Hamd," you should know that these are mere whisperings and disregard them. You should also disregard the doubts that you have after making Sujood (prostration) about saying "Rabbana wa laka Al-Hamd." These are all symptoms of Waswaas. We implore Allah to safeguard you from it.
It should be noted that saying "Rabbana wa laka Al-Hamd," is an act of Sunnah according to the majority of scholars. So if you do not say it, even if deliberately, then the prayer is not invalidated.
Allah knows best.
You can search for fatwa through many choices