Answer:
Ophelia is truly mad. She goes mad after her father is murdered (unintentionally) by Hamlet. Before he accidentaly killed her father, Hamlet also rejected Ophelia. She had thought she loved him and in combination, his rejection of her and the murder of her father drove her to insanity.
Hamlet's "madness" is not a true madness. It is never truly revealed whether or not he is legitimately mad at any point in the play. He claims that he will "put on an antic disposition" and therefore act mad. His madness that follows in the rest of the play is most likely just an act since he has moments when he seems to be completely sane.
Therefore, Ophelia's madness is a true madness which she was driven to by unfortunate circumstances while Hamlet's madness may just be an act that he chooses to put on as he plans to kill Claudius.