And also, what were the procedures people had to go through in the mental hospitals?
The M'Naghten rules were rules, defined in 1843 by the House of Lords, which defined the standards for an insanity defense: this defense could only suceed in cases where the accused was rendered unable to appreciate the wrongness of his act, or even thenature of the act itself.
The historical basis for this rule came from the Normand era, with the "wild beast" standard; a more precise and modern version of the standard was made in R v Arnold (1724):
whether the accused is totally deprived of his understanding and memory and knew what he was doing "no more than a wild beast or a brute, or an infant".
As for the admission in asylums, as they were then called, the Criminal Lunatics Act 1800 mandated the detention "to Her Majesty’s pleasure" of persons who have been acquitted of treason or any felony for insanity. For the others, it appears that, before 1890, there were not many public "madhouses," making people with mental illness be sent in private institutions or in workhouses, prisons and houses of corrections under the poor law or vagrancy law; county asyloms were also available.
Sources: