i have 2 ways that i have done it:
1. drill a hole all the way through the pvc. you wont catch your edge on the hole on top if you file/countersink it. then just put your screw down in, put a little glue in the hole in the wood, and your set
2. I did this on a small rail that i actually put 2 pieces of pvc pipe in the ground and the legs go in the pipes so i can take it out in the summer and leave the pvc pipes in the ground. but what i did was cut a 2 rectangles out of the bottom of the pvc pipe that was for the rail, stuck two small pieces of wood in them, drilled a hole through the side, and bolted them onto the pvc pipe. dont ask me how i cut the holes in the pvc because i dont remember.
some people say drill up through the bottom but this is not as sturdy as drilling for the top down