Messenger of Allah said: "When the Imam says: (Sami Allahu liman hamidah) 'Allah listens to those who praise Him. Then (all of you) say: (Rabbana wa lakal-hamd) 'O our Lord! And to You is the praise for whoever's saying concurs with the saying of the angels, then his past sins will be forgiven."
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا قَالَ الإِمَامُ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ فَقُولُوا رَبَّنَا وَلَكَ الْحَمْدُ فَإِنَّهُ مَنْ وَافَقَ قَوْلُهُ قَوْلَ الْمَلاَئِكَةِ غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ