Replacing P-traps require that you remove the old trap first, and inspect the fixture to find the source of the problem. It may be so that the trap is cracked, or it is not installed in the right way, causing the sewer gases to leak out. After making sure that the cause of the problem is P-trap, wear your face mask and use a spanner to unscrew the bolts attached with the trap. Use a small bowl to catch water below the trap, and then remove the nuts on either side of the trap with the help of pliers. Take off the trap and empty its contents into the bowl.
Remove the trap arm by using a spanner to loosen the trap arm nuts, and take the arm out of its place. The pipe may get clogged or corroded and it may require a lot of effort on your part to take it out of the wall.
Purchase all pieces required for installing a new P-trap, and set them up properly. Lay all the pieces on the floor so that you get an idea that which piece goes where.
First piece to install is the new p-trap arm. Use a slip joint washer tapered at one end, and use two bolts to attach it.
If the arm pops out of the floor, use a pipe cutter to cut it to the required size. Now, fix the P-trap in the arm with your bare hands and press it gently to make it water tight. Install the sink over the trap and run water through the link to make sure you have installed the P-trap right.