The Messenger of Allah ﷺ said, "When one of you is uncertain about his prayer, let him cast aside the doubt and build upon what he is certain of. Once he is sure he has completed the prayer, let him perform two prostrations. If his prayer was already complete, the extra unit counts as a voluntary prayer, and if it was deficient, the unit completes his prayer, while the two prostrations rub the nose of Satan in the dust."
حدثنا أبو كريب حدثنا أبو خالد الأحمر عن ابن عجلان عن زيد بن أسلم عن عطاء بن يسار
قال رسول الله ﷺ إذا شك أحدكم في صلاته فليلغ الشك وليبن على اليقين فإذا استيقن التمام سجد سجدتين فإن كانت صلاته تامة كانت الركعة نافلة وإن كانت ناقصة كانت الركعة لتمام صلاته وكانت السجدتان رغم أنف الشيطان