The pill

I get super bad cramps when I get my period and I also throw up and get diarrhea. I was talking to my friend about this and she said the same thing happened to her when she got her period so she went to the doctor and they put her in the pill and I was considering to get it too because I can't bear my cramps. And I was just wondering if that pill is the same for birth control? Like if I get the pill for cramps could I also use it for preventing pregnancy?