It is narrated from Sayyiduna Abu Umamah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever clears phlegm in the mosque and does not bury it, it is a bad deed; and if he buries it, it is a good deed."
Hadith Referenceالمعجم الكبير للطبراني / باب الصاد / 8061