The Sunnah of relieving oneself and a mentioning of the various rules and regulations that come along with that.
One should always move and hide away from others when relieving oneself.
As an added note, the word ‘toilet’ in this article refers only to the area immediately surrounding the place of relief and not, as is commonly understood in English, the entire bathroom.
As an added note, the Prophet (ṣallallāhu ʿalayhi wa-sallam) said, “To put a barrier that will prevent the jinn from seeing the ʿawrah of the sons of Ādam, let any one of you say ‘Bismillāh’ when entering the toilet.”  One should enter the toilet with the left foot first  and say whilst entering: “Allāhumma innee a’oodhubika minal-khubuthi wal-khabaa‘ith.”  [O Allāh, verily I seek refuge in you from all evil things. It could also mean, O Allāh, verily I seek refuge in you from the male and female jinns ]. It is known that the jinn like to inhabit places of filth, such as toilets and camel pens and that is why we have been ordered to seek refuge in Allāh from their harm when we enter the toilet. 
One should always move and hide away from others when relieving oneself. Jābir (raḍī Allāhu ʿʿʿanhu) relates that, “When the Prophet (ṣallallāhu ʿalayhi wa-sallam) felt the need of relieving himself, he went far off where no one could see him.”  He (ṣallallāhu ʿalayhi wa-sallam) would also take the added precaution of not raising his garment until he had lowered himself near the ground , since, even thought he would go to a far off place to relieve himself, the area was still open, so there was still the possibility of being seen. This is an indication of extreme sense of modesty and shyness which the Prophet (ṣallallāhu ʿalayhi wa-sallam) possesses. In contrast, we see the disbelievers, especially the men, who feel no shame in using public urinals, exposing themselves to everyone. There are certain places which we have been expressly told to avoid when relieving oneself. The Prophet (ṣallallāhu ʿalayhi wa-sallam) said, “Beware of those acts which cause other to curse.” They asked, “What are those acts,” he said, “Relieving yourself in the people’s pathways or in their shade [under trees].”  This ḥadīth illustrates beautifully how Islām safeguards the rights of one and all. Again, in marked contrast to this, we find the manners of the disbelievers, whose inconsiderate behaviour leaves foul stenches in several phone booths and subways. Not only that, but they see no wrong in walking their dogs with the specified purpose of fouling the paths, causing harm and offence to others.
 THE PROHIBITION OF FACING THE QIBLAH:
The Prophet (ṣallallāhu ʿalayhi wa-sallam) said, “If you go to defecate, do not face the Qiblah nor turn your back toward it. Instead, you should turn to your left side or your right.”  Some scholars are of the opinion that this forbiddance only applies in open areas and that if you are in an enclosed place, then there is no harm relieving yourself facing the Qiblah or with your back towards it. Ibn ʿUmar (raḍī Allāhu ʿʿʿanhumā), said, “If there is between you and the Qiblah, something shielding you, there is no harm in it.”  The more correct opinion however (and Allāh knows best), seems to be that it is something forbidden in both and open and concealed areas and it is best to refrain from doing so as far as possible out of respect for the direction which we pray in. The problem which faces many people regarding this issue is what to do if the toilets that they use are positioned in such a way that they cannot help but face or have their back toward the Qiblah. The answer to this can be found in the example of the Companions (raḍī Allāhu ʿʿʿanhum), for they too faced this problem after they had conquered Shaam (Syria) which had formerly been occupied by the Christians. The Companions (raḍī Allāhu ʿʿʿanhum) mentioned that when they had to use these toilets, then when they came out, they would ask for Allāh’s forgiveness. 
It is recommended (mustahabb) to urinate whilst sitting or squatting and not standing, since this was the usual practice of the Prophet (ṣallallāhu ʿalayhi wa-sallam).  It is not forbidden (ḥarām) to stand whilst urinating since the Prophet is also reported to have done so, but sitting/squatting is better since this is healthier for the body and because there is less chance of urine splashing onto one's body or clothes. Great care must be taken to avoid the splatter of urine on oneself, since urine is something impure. The Prophet (ṣallallāhu ʿalayhi wa-sallam) once passed by two graves and said: “Both are being punished. They are not being punished for major [sins]. One did not shield himself from urine and the other carried gossip.” 
It is forbidden to use the right hand in order to clean oneself from the impurities of urine and feces. The Prophet (ṣallallāhu ʿalayhi wa-sallam) said, “None of you should touch his privates with his right hand whilst urinating nor should he wipe of feces with his right.”  As for the material which should be used for cleaning, then we can use either dry material (i.e. tissue paper, stones, etc.) or water. It is permissible to use one or the other, or both and out of the two, water is better. This is known by the fact that the āyah,
“Allāh loves those who make themselves clean and pure…” [Sūrah al-Tawbah9:108]
was revealed in connection with the Ansār (the Helpers) of the Qoobaa (near al-Madīnah) because they would use water to cleanse themselves after going to the toilet.  This was also the usual practice of the Prophet (ṣallallāhu ʿalayhi wa-sallam).  There are three requirements for the dry material if it is to be used to clean oneself: [i] it must be something pure in itself (i.e. tissue paper, pebbles); [ii] it must not be something which is respected (i.e. a book) or something which is of use (i.e. food, clothes etc.); [iii] the private parts must be wiped at least three times with clean parts of that material.  After cleaning the private parts, one should clean one’s hands. Abū Hurayrah (raḍī Allāhu ʿʿʿanhu) related that after cleansing himself, the Prophet (ṣallallāhu ʿalayhi wa-sallam) would rub his hand on the ground (to clean it) and then he would perform ablution. 
 STEPPING OUT:
The Prophet (ṣallallāhu ʿalayhi wa-sallam) would exit the toilet area with his right foot first and seek Allāh’s forgiveness. ’Aa‘ishah (raḍī Allāhu ’anhaa) reported that when he left the toilet, he would say: “Ghufraanaka.” (I seek your forgiveness).  May Allāh grant us the ability to model our whole life on that of the Prophet’s and may He bless us with those actions which are pleasing to Him. He is the best One to ask and the greatest One who responds.
 Ṣaḥīḥ: Related by al-Tirmidhī (no. 551), and it was authenticated by Shaykh Muḥammad Nāṣir al-Dīn al-Albānī in Ṣaḥīḥ al-Jāmiʿ(no. 3611).
 Since the toilets in the time of the Prophet (ṣallallāhu ʿalayhi wa-sallam) were not confined to a structural building, but rather the open space was used, there is no proof for entering with the left foot. However, Ibn Ḥajar in Fat′h al-Bārī says that “…it may be understood by some by the Prophet's love of beginning good and pure things with the right hand/side that this (entering the toilet) falls into the opposite category.”
 Related by al-Bukhārī (1/144) and Muslim (1/729), from Anas Ibn Mālik (raḍī Allāhu ʿʿʿanhu).
 Jinns are being created from smokeless fire who live on earth but are not visible to humans. They posses free will and so like mankind, there are believing and disbelieving jinns.
 It is also the reason why we have been prohibited to pray in toilets, camel pens and the like. Refer to Abū Dāwūd (1/492; 1/184) and others.
 Related by Muslim (1/519) and Abū Dāwūd (1/2).
 Ṣaḥīḥ: Related by Abū Dāwūd (1/14), from Ibn ʿUmar (raḍī Allāhu ʿʿʿanhu).
 Related by Muslim (1/516) and others from Abū Hurayrah (raḍī Allāhu ʿʿʿanhu). The Prophet (ṣallallāhu ʿalayhi wa-sallam) also prohibited relieving oneself in standing water; refer to Muslim (1/553).
 The Qiblah is the direction of the Kaʿbahin Makkah i.e. the direction which the Muslims face when they pray.
 Related by al- Bukhārī (1/146) and Muslim (1/507), from Abū Ayyūb al-Anṣārī (raḍī Allāhu ʿʿʿanhu).
 Ḥasan: Related by Abū Dāwūd (1/11) and others. It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ Sunan Abī Dāwūd (1/8).
 Ṣaḥīḥ: Related by Abū Dāwūd (1/9) and others. It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ Sunan Abī Dāwūd (1/7).
 Ṣaḥīḥ: Related by Abū Dāwūd (1/22). It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ Sunan Abī Dāwūd (1/16).
 Related by al-Bukhārī (1/217) and Muslim (1/575) from Ibn ʿAbbās (raḍī Allāhu ʿʿʿanhu).
 Related by al-Bukhārī (1/155) and Muslim (1/513) from Abū Qatādah.
 Ṣaḥīḥ: Related by Abū Dāwūd, from Abū Hurayrah. It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ Sunan Abī Dāwūd (1/7).
 Related by al-Bukhārī (1/152).
 Related by Muslim (1/504), from Salmān al-Faarsee (raḍī Allāhu ʿʿʿanhu) It should perhaps be mentioned (for the sake of completeness) that the use of dung and bones to clean oneself is also prohibited, the reason being that our brothers for the Jinn find food on it. Refer to al-Bukhārī (5/200).
 Ḥasan: Related by Abū Dāwūd (1/45). It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ Sunan Abī Dāwūd (no. 35).
 Ṣaḥīḥ: Related by Abū Dāwūd (1/30). It was authenticated by Shaykh al-Albānī in Ṣaḥīḥ al-Tirmidhī (1/7).