All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
There is no blame upon the Muslim if he says to the Prophet, sallallaahu ‘alayhi wa sallam, at his grave: “Peace be upon you, O Messenger of Allaah.”
The companions used to do this as well as those who followed them. This is indicated by the Hadeeth in which the Prophet, sallallaahu ‘alayhi wa sallam, said: “If any one of you greets me, Allaah returns my soul to me and I respond to the greeting.” [Abu Daawood]
The Prophet, sallallaahu ‘alayhi wa sallam, also said: “I hear whoever asks Allaah to confer blessings upon me near my grave, and I am informed about whoever asks Allaah to confer blessings upon me far away.” [Narrated by Abu Ash-Shaykh in Ath-Thawaab]
Al-Haafith said in Al-Fat-h: its chain of narrators is good. Maalik and Ahmad narrated on the authority of Naafi' that Ibn ‘Umar used to say, upon entering the Masjid: “Peace be upon you, O Messenger of Allaah, peace be upon you, O Abu Bakr and peace be upon you, father.”
Concerning supplication, do not supplicate while facing the grave. After greeting the Prophet, sallallaahu ‘alayhi wa sallam, you may supplicate while facing the Qiblah, as narrated by Ibn ‘Umar, Anas and others. This is the opinion of the four Imams.
Allaah Knows best.