I know that you need say alhamdulilah after sneezing even if you are in middle of a prayer. But sometimes I sneeze in toilet. But in toilet what I know you are not allowed to say Allah's name. So I should not say alhamdulilah if I need to sneeze in toilet?
In the following I'll explain the problem in detail and what are the scholarly views on it, feel free to jump down to the conclusion if you want a quick answer!
Two opposite recommendations
We have here two opposing recommendations:
- A person should thank Allah after sneezing by saying:
Two men sneezed before the Prophet. The Prophet (ﷺ) said to one of them, "May Allah bestow His Mercy on you," but he did not say that to the other. On being asked (why), the Prophet (ﷺ) said, "That one praised Allah (at the time of sneezing), while the other did not praise Allah."
... When any one of you sneezes he should praise Allah and the other should say: May Allah have mercy upon you, and if he does not praise Allah, no mercy should be begged for him. (Sahih Muslim)
- it is agreed upon among scholars that if one is in a toilet (not a bath in which there's a section for washing and a section for peeing and defecating) that one shouldn't speak and remain silent until one has finished (note that speaking in such a case is frowned upon "makrooh" not prohibited "haraam"!) and is leaving, but while entering it is recommended to follow the sunnah and performing the dhikr or du'a mentioned here and when leaving the dhikr or du'a mentioned here. Among the evidences for this is:
Muhajir came to the Prophet (ﷺ) while he was urinating. He saluted him. The Prophet (ﷺ) did not return the salutation to him until he performed ablution. He then apologised to him, saying: I disliked remembering Allah except in the state of purification.
(Sunan abi Dawod)
This consensus however doesn't apply in case of necessity such as if one saw something dangerous happening and would need to call or speak to save a soul, like being a snake which may attack a person or a blind man falling in a well etc. as stated by imam an-Nawawi in his al-Majmo'a المجموع شرح المهذب -see here-.
Some remarks first
In case of sneezing there's no backup for the person who sneezed that he/she should do more than thanking Allah. The part of answering "Alhamdulillah" (from this person) is a due on those people who heard him utter this thank.
As for our case of silence while defecating or peeing we already saw that the Messenger of Allah () didn't answer a person greeting him until he finished, while answering the Salam (Greeting) is regarded as fard (obligation) the same applies for similar situation such as greeting a person during the jumu'ah khotbah the answer should wait until the khotbah or prayer is done.
A Sahih narration on the same topic however says that the prophet () didn't answer a greeting (See in Sahih Muslim).
I want to point again at the fact that our case 1., is a recommendation, while case 2. is a discouragement not a prohibition!
Let's know find a way out of the opposite recommendations.
There's a huge scholarly dispute on the matter, so for some reasons some say it is permissible to utter the dhikr, others say it is permissible to say it in mind others even say it isn't.
Some scholars used the hadith:
The Apostle of Allah (ﷺ) used to remember Allah at all moments.
and the verse:
...To Him ascends good speech... (35:10)
as an evidence to declare it permissible, however it is more preferable to say it in your mind. Among the scholars who were reported to regard it permissible are: an-Nakha'i النخعي, a-Sha'abi الشعبي, 'Abdullah ibn 'Amr ibn al-'Aas عبد الله بن عمرو بن العاص, ibn Sireen ابن سيرين and Malik ibn Anas مالك بن أنس and it was also reported to be regarded frowned upon by ibn'Abbas ابن عباس, 'Ataa' عطاء, a-Sha'abi الشعبي and others as stated by al_Qadi 'Iyad in his Ikmal al-Mu'allim إكمال المعلم بفوائد مسلم (see here).
While imam al-Qurtobi discussed the verse:
Who remember Allah while standing or sitting or [lying] on their sides ... (3:191)
He took the occasion to point at the fact that these tree cases, i.e. standing, sitting or lying, are describing almost all states of a human saying: In the following I'm translating from Arabic language as these translations are of my own take them carefully.
ذكر تعالى ثلاث هيئات لا يخلوا ابن آدم منها في غالب أمره، فكأنها تحصر زمانه (Source)
The Almighty mentioned three forms that the son of Adam is not free from in most of his affairs, as if they limit his time
This statement beside the hadith of 'Aishah describing that our prophet () was remembering Allah in all moments, lead him to the conclusion that the case of being in a toilet is covered here as he regarded the message of the verse as general.
The above are only a couple of statements of scholars, some scholars also pointed at the difference between the case of a closed location for defecating and peeing such as toilet and the case of doing this outside a closed location -in free space- in a forest or desert etc., even in this case it's regarded as frowned upon to do it i.e. under trees (but here one should check the details, which are irrelevant here)
To sum up there's a difference of opinion on the topic of saying "Alhamdulillah" after sneezing while in a toilet, between regarding it frowned upon or permissible. The strongest of which is that in these cases, it is permissible and the safest option is to do this in the mind and not utter it with the tongue.
Some references I've used in this answer (if not otherwise said all in Arabic):
- A study of Sheikh 'Abdurrahman as-Sudais.
- Fatwa islamweb #8501 on the topic of the question and #158517 on the topic on speaking while in a toilet.
- Fatwa islamqa #297964 on the topic on speaking while in a toilet and closing doors etc.
- Fatwa of ibn Baz on dhikr in the toilet or bathroom.
- Fatwa islamqa -in English- #145679 "Is it prescribed for a person who sneezes, when he praises Allah, to say “Yarhamuk Allah (May Allah have mercy on you)” to himself?".