Measure the length of the bed with a tape measure, and determine exactly where you want the bed rail to go on the bed. Measure the width in the same manner. Most bed rails will start along the side of the bed and go up about 12 inches.
Cut four 1-inch thick pieces of PVC to size with a hacksaw. Mark the cut locations with a pencil for the two pieces that will make up the width. Cut carefully along those lines with a hacksaw. Move the hacksaw back and forth in the PVC until it is cut in two. Repeat the process for a second piece. These two will serve as the top and bottom of the bed rail.
Cut the two smaller pieces with a hacksaw in the exact same manner as you did in step two. These two pieces will serve as the height of the bed rail. Wipe off the cut ends of all of the pieces with a clean rag to remove the shards left over from the PVC.
Connect all of the pieces together with 1-inch 90 degree elbows. Slide the elbow into the end of the long piece, and attach it to a shorter piece. Attach an elbow to the other end of the shorter piece, and slide the second longer piece into the elbow. Attach the third elbow to the end of the longer piece, and slide the second shorter piece into the third elbow. Connect the final elbow between the last two pieces to form the bed rail.