The Messenger of Allah ﷺ said, "When one of you is uncertain about his prayer and does not know how much he has prayed, let him build upon what he is certain of, and once he is sure he has completed the prayer, let him perform two prostrations before giving the salam. For if his prayer was an odd number, these will make it even, and if it was already even, they will be a humiliation for Satan."
حدثنا يونس بن محمد حدثنا فليح عن زيد بن أسلم عن عطاء بن يسار
أن رسول الله ﷺ قال إذا شك أحدكم في صلاته فلم يدر كم صلى فليبن على اليقين حتى إذا استيقن أن قد أتم فليسجد سجدتين قبل أن يسلم فإنه إن كانت صلاته وترا صارت شفعا وإن كانت شفعا كان ذلك ترغيما للشيطان