There is authentic evidence that the Prophet (peace be upon him) had long hair.(length of his hair was till his Earlobe)(according to: http://en.islamtoday.net/node/1126)
Long hair for men is allowed (actually short hair is better for men, although long hair is allowed too but they should take care of their hair).
Our actions are only by our intention. If someone keeps his hair long to emulate the Prophet (peace be upon him) and take care of it and care about hygiene of them, then it’s ok. On the other hand, if he keeps long hair to emulate the appearance of a certain religious sect or to resemble women, then he is committing a sin that makes him eligible for punishment(http://en.islamtoday.net/node/1126) according to this hadith:
The Prophet (peace be upon him) said: “Allah curses men who immitate women and women who immitate men.” [Sunan Abî Dâwûd, Sunan Ibn Mâjah, and others]
Women can have long hair, too. Even it 's one of Beauty signs in different cultures.
Finally, someone may grow his/her hair long based on his/her interest. So, with lack of the above stated reasons; it is permissible for him/her to do so, but it should be in the cultural and usual limitation and they should care about its hygiene.
For answering I used this links: