Buying pills and medicine online can be done safely and legitimately.
You just have to make sure the online store or company you buy the pills or other medicine online from are legit.
If it's prescription medicine you need to have your prescriptions because it can be illegal to purchase prescription medicine online without the doctors prescription for those medicines.
I've bought other types of pills such as aspirin, sleeping pills etc through ebay and never had a problem doing so but I've never bought any prescription medicines online.
I always just go to the pharmacy in my town and pick up my prescription medicines which is faster and safer.