It can happen when you least expect it. You could be getting a drink at a bar, having a meal with friends or family, or enjoying a day at the beach. Suddenly, your phone is soaking wet. Whether someone spilled a drink on it or you dropped it doesn't matter; your portable tether to the rest of the universe is gone.
But, there are ways to fix it yourself, and avoid having to buying another phone. First, even if you're going through the first stages of grief and want to check to see if your phone still works, DO NOT TURN IT ON. Doing so can short the device's circuits, eliminating any chance of later repair.
That being said, not all liquids are created equal. Plain water is much easier on your phone than beer or salt water. Not only do the latter liquids leave a residue of sticky, dissolved material on (or inside) your phone, but they are also more corrosive to the phone components because of their electrolytes. If your phone was soaked with anything besides water, give it a quick rinse first.
Next, dry it off with a towel and take out the SIM card and battery. If you have an iPhone, this may be the hardest step. The SIM card (the chip that holds your phone information and contacts) is in a slot either on the top or side of the phone. You can trigger it to pop out by sticking an unfolded paper clip into a hole near it. However, the battery is in the phone's innards, and two small screws stand in your way. If they are the infamous pentalobe screws, you might not be able to get to the battery at all. Only a few specialty screwdrivers can unscrew them, and you won't have the time to get one from Amazon. The phone should still be okay, as long as you don't turn it on. On other types of phone, the battery and SIM card are much easier to reach.
Get rid of as much moisture as you can in your phone. Don't use a blow dryer, since this can permanently ruin the device. Instead use a vacuum cleaner on low to suck out all the droplets. Lastly, place it in a bowl or bag, cover it with uncooked rice, and store it in a warm place for at least 24 hours. The rice should take care of any leftover moisture. It's best if you take off the back of the phone, although with iPhones this might not be possible.
After the rice-drying process, remove the phone and turn it on. It might not work so well at first, but give it a few good days and all of its functions should return. Hopefully.