As one of the rituals for visiting the dead, the visitor is recommended to address the dead by saying this statement: “Peace be upon you all which are lying in the Believers’ resting place; we shall, Allah willing, join you.”
According to Ijtihadnetwork, Al-Azhar Stresses: Visiting the Graves and Laying Flowers on them Prophet’s Sunnah (practice).
The fatwa committee of Al-Azhar’s Islamic Research Center answered a question regarding visiting the tombs of the dead.
The full text of the question and its answer is as the following:
Question: what is the fatwa for visiting the dead and laying flowers on their tombs?
Answer: visiting the dead is Prophet Muhammad’s Sunnah (practice), as the Prophet said: Visit the tombs as it reminds you of the Hereafter.
As one of the rituals for visiting the dead, the visitor is recommended to address the dead by saying this statement: “Peace be upon you all which are lying in the Believers’ resting place; we shall, Allah willing, join you” (السلام علیکم دار قوم مؤمنین و إنا أن شاءالله بکم لاحقون).
“There is reason for laying flowers on the tombs in the Prophet’s Sunnah, as it is narrated from Ibn Abbas that someday while the Prophet (P.B.U.H) was passing across a wall in Medina or Mecca he heard the voices of two men who were being tormented in their graves. The Prophet (P.B.U.H) said that they were being tormented and that their torment was not for a great sin. He then said: one of them used not to cover his body when he urinated, and the other was a calumniator. The Prophet (P.B.U.H) then requested a bough of a young tree and cut the same into half and laid each one on the graves mentioned. The Prophet (P.B.U.H) was asked about the reason why he did so. He replied: in the hope that their torment get softened until these two boughs are dried”, Al-Azhar added.