Is it true that Prophet $Muhammad$$ (Sallallahu Alaihi wa Sallam) told his Ummah not to collect Hadith and make another book besides the holy Qur'an? Then what about Sahih $Bukhari$$ and Sahih $Muslim$$ and $Tirmizi$$?
Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions. Muslim reported from Abu Said al-Khudri (Radiya Allahu Anhu) that the Prophet (Sallallahu Alaihi wa Sallam) said: "Do not write anything from me except the Qur'an and whoever has written anything else apart from the Qur'an should wipe it off" . But there are many Ahadith that allow writing the Hadith. al-Bukhari and Muslim reported from Abu Hurairah (Radiya Allahu Anhu) that "a man called Abu Shah from Yemen attended the sermon that the Prophet (Sallallahu Alaihi wa Sallam) gave the day of the conquest of Makkah he (this man) said: 'Write for me' (what has been said in the sermon). The Prophet (Sallallahu Alaihi wa Sallam) said: "Write for Abu Shah " . Al-Bukhari reported from Abu Hurairah that he said: "None of the companions of the Prophet (Sallallahu Alaihi wa Sallam) knew more Hadith than I except Abdullah Ibn Umar because he used to record and I did not use to record" . As a result there was a disagreement among the scholars of the Salaf (companions and those who immediately came after them) over the issue of writing the Hadith. Some of them disliked it. But most of them allowed it. Later on there was a consensus among all Muslims to record the Hadith and the disagreement was removed. These differences of opinion were regarding the trustworthiness of some narrators' ability to memorize. Some people whose memories are weak, might change the Hadith while reporting it. This in turn, could lead to some misunderstanding of some Islamic concepts and principles. Some scholars believe that those Hadith that establish the objection to writing the Hadith are nullified and the objection was only when there was fear that recording the Hadith and the Qur'an in the same pamphlet might cause confusion. Now that those fears were dispelled then all the Muslim scholars are of the opinion that the Hadith should be recorded. There is consensus on this issue after the initial disagreement among Muslims during the first century after the Prophet (Sallallahu Alaihi wa Sallam). As a result many Hadith books such as 'al-Bukhari', 'Muslim' and others were collected. Allah knows best.
You can search for fatwa through many choices