BAYHAQI 4321:
from Muḥammad b. Sinān al-Qazzāz from my father —
"The Messenger of Allah said: 'When anyone of you enters the mosque, let him send peace upon the prophet, then let him say: "Allahummaftah li abwaba rahmatika (O Allah, open to me the gates of Your mercy)." And when he leaves, let him say: "Allahumma inni as'aluka min fadlika. (O Allah, I ask of you from Your bounty)." (Using translation from Ibn Mājah 772)
البيهقي ٤٣٢١:
عن محمد بن سنان القزاز عن أبي —
أَنَّ رَسُولَ اللهِ ﷺ قَالَ إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلْيُسَلِّمْ عَلَى النَّبِيِّ ﷺ وَلْيَقُلِ اللهُمَّ افْتَحْ لِي أَبْوَابَ رَحْمَتِكَ وَإِذَا خَرَجَ فَلْيُسَلِّمْ عَلَى النَّبِيِّ ﷺ وَلْيَقُلِ اللهُمَّ أَجِرْنِي مِنَ الشَّيْطَانِ الرَّجِيمِ
hadithunlocked.com