Old toilet soil pipes--known as sewer pipes--are usually made of clay, lead or cast iron. As new code requires either PVC or ABS (acrylonitrile butadiene styrene) plastic, it's best to replace the old pipe and bring the sewer up to code. A new PVC or ABS pipe can be joined to the old pipe with a flexible rubber coupling.
Mark the old pipe at the point where you want new sewer pipe to connect to it. If the old pipe is cast iron or lead, cut through it at the mark with a hacksaw. If the old pipe is clay, use a cut-off saw. Make sure that the cut is straight, and remove any burrs with a utility knife.
Remove all the old pipe by taking out the screws around the toilet flange lip, and cutting the old sewer pipe into 3-foot sections (the toilet flange and elbow joint connected to it can be pulled up out of the flange hole in the bathroom floor).
Push one end of a flexible rubber coupling onto the end of the existing sewer pipe, so that the pipe is pushed halfway into the coupling--the new sewer pipe will insert into the other half of the coupling. Tighten the metal strap around the end of the coupling with a screwdriver.
Insert a new ABS toilet flange down into the bathroom floor hole, so that its lip rests on the floor. Apply ABS glue around the inside bottom of the flange, and around the outside male end of a 90-degree ABS elbow joint. Push the elbow joint up into the flange, and hold for 30 seconds.
Apply glue to the end of a new piece of ABS sewer pipe, as well as the inside of the female end of the elbow joint. Push the pipe into the elbow joint, and hold for 30 seconds. Now measure, cut and install new sewer pipe until it reaches over to the flexible rubber coupling.
Push the end of the sewer pipe into the rubber coupling, and then tighten the metal strap surrounding the end of the coupling, with a screwdriver.
Install 1 5/8-inch galvanised screws around the lip of the toilet flange, securing it to the toilet floor.
If installing PVC sewer pipe, use PVC primer to prime all joints first, before using PVC glue to seal the joints. Make sure all horizontal sewer pipe is installed at a gradient to allow for waste to travel down the pipe. Consult the local city building department for the correct gradient in your area.