So long as you are still conscious and understand the prayer and are following the imam, then your prayer is valid and the basic principle is that you have done what the imam does. This is the basic principle and this is what you have apparently done with the imam, unless you know something to the contrary. If you know that you did not recite al-Faatihah, you should recite it and then say the salaam after that; if you know that you did not recite the tahiyyaat with the imam, recite it and then say the salaam. If you know that you omitted al-Faatihah in one of the rak’ahs, then the matter is broad in scope, because the imam will carry that responsibility for you in the event that you forgot it or did not know that you should recite it; or if you do not know what you did, the imam will carry that responsibility for you, in sha Allah. End quote.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him).