Fatimah bint Rasullulah ﷺ reported,

Whenever the Messenger of Allah ﷺ entered the mosque, he would say, "In the name of Allah, and peace be upon the Messenger of Allah. O Allah, forgive me my sins and open to me the gates of Your mercy."And when he left, he would say, "In the name of Allah, and peace be upon the Messenger of Allah. O Allah, forgive me my sins and open to me the gates of Your bounty."

Ibn Majah 771

Daif

حدثنا أبو بكر بن أبي شيبة حدثنا إسمعيل بن إبراهيم وأبو معاوية عن ليث عن عبد الله بن الحسن عن أمه

عن فاطمة بنت رسول الله ﷺ قالت

كان رسول الله ﷺ إذا دخل المسجد يقول بسم الله والسلام على رسول الله اللهم اغفر لي ذنوبي وافتح لي أبواب رحمتك وإذا خرج قال بسم الله والسلام على رسول الله اللهم اغفر لي ذنوبي وافتح لي أبواب فضلك

ابن ماجه 771ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Mosques and congregations
Chapter
Supplication upon entering the masjid
Numbering
Darussalam 771
Ibn Majah 771