The problem with carpet water damage is that the water often seeps down into the underfloor as well. Even if you dry the carpet out, this seeping water can cause problems beneath it, and you will often need to replace the underlayment as well as sections of the carpet. Usually, if the carpet is not cleaned and dried out within 48 hours, then it needs to be replaced. You should also be very careful when drying out the carpet, because drying out a carpet improperly can make it stretch or warp.
An expert can advise on the different types of carpet and how best to dry them out, but often you will need to raise the carpet up from the floor and set fans and dehumidifiers around the room to dry it out, preferably equally throughout the damaged portion. Make sure the entire room and subfloor is dry before reattaching or replacing the carpet, because any leftover dampness will attract mold. If the carpet has been exposed to any sort of contaminated water, be prepared to replace it no matter what, because this can pose health hazards if it remains. To get rid of less dangerous dirt, try steam cleaning or vacuuming with a sprinkling of baking soda.
If drywall has been exposed to water, it is important that you cut out the sections that have been affected. This drywall itself is probably ruined, and removing the section will help the wall breathe, drying out any trapped water and avoiding further damage to the inner wall and other drywall sections. If the drywall looks simply discolored and is not sagging or warped, then you may be able to restore it with shellac material.
After removing the drywall and drying out the inner wall, you can place a patch on the open area, installing a new drywall section with some spackle to smooth out the edges. The wall will need to be repainted afterward. You can replace the drywall with a water-resistant version if you feel inclined.