“The Messenger of Allah ﷺ said: ‘If anyone of you is uncertain about his prayer, let him try to do what is correct then let him prostrate twice.’” Tanafisi said: "This is the basic rule, and no one is able to reject it."
رَسُولُ اللَّهِ ﷺ إِذَا شَكَّ أَحَدُكُمْ فِي الصَّلاَةِ فَلْيَتَحَرَّ الصَّوَابَ ثُمَّ يَسْجُدْ سَجْدَتَيْنِ قَالَ الطَّنَافِسِيُّ هَذَا الأَصْلُ وَلاَ يَقْدِرُ أَحَدٌ يَرُدُّهُ