The Prophet ﷺ said, "If any of you is uncertain about his prayer, and he is sure that he has prayed three rakats, let him stand and complete one more rakah with its prostrations, then sit and recite the tashahhud. When he finishes and nothing remains but to give the salam, let him perform two prostrations while seated, then give the salam."Then he mentioned the meaning of Malik's narration.
حدثنا قتيبة حدثنا يعقوب بن عبد الرحمن القاري
إن النبي ﷺ قال إذا شك أحدكم في صلاته فإن استيقن أن قد صلى ثلاثا فليقم فليتم ركعة بسجودها ثم يجلس فيتشهد فإذا فرغ فلم يبق إلا أن يسلم فليسجد سجدتين وهو جالس ثم ليسلم ثم ذكر معنى مالك