Crying causes headaches by dehydrating you. To prevent a headache, be sure to drink lots of water or other liquids. When you get hydrated again, your headache should go away.
That would be because you are stressed out. Usually when you cry it stresses you out. When you are crying remember to breath since it can be hard to do when you are crying.