Ibn Buhayna reported,

The Prophet ﷺ stood up after the second rakah of the noon prayer, forgetting to sit. When he had finished his prayer with only the closing salutation remaining, he performed the two prostrations of forgetfulness and then gave the salutation.

Ibn Majah 1207

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا ابن نمير وابن فضيل ويزيد بن هارون ح و حدثنا عثمان بن أبي شيبة حدثنا أبو خالد الأحمر ويزيد بن هارون وأبو معاوية كلهم لهم عن يحيى بن سعيد عن عبد الرحمن الأعرج أن

ابن بحينة أخبره

أن النبي ﷺ قام في ثنتين من الظهر نسي الجلوس حتى إذا فرغ من صلاته إلا أن يسلم سجد سجدتي السهو وسلم

ابن ماجه 1207صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Standing up from two rakats forgetfully
Numbering
Darussalam 1207
Ibn Majah 1207