Measure the width of your bed and add 2 inches. Determine how tall you want the headboard to be. The standard headboard height is 44 inches, including 18 inches behind the bed. If you want to mount the headboard directly to the wall behind your bed, your plywood should be 26 inches tall.
Purchase 1/2-inch plywood from a home store. Place the wood on a sawhorse and use a chalk line to mark off the size to fit your earlier measurements. Cut along the straight line with a circular saw and sand all the edges until they are smooth.
Cut the foam to fit the headboard measurements exactly, and then trim your batting. Add an overlap of 6 inches on each side so that you can wrap it around the foam and plywood.
Iron your fabric. If it is patterned, line it up carefully on the headboard before cutting it to size, allowing 6 inches of overlap around the layers. When you are satisfied with the alignment, lay the fabric on a flat surface and line up the batting above it. Center the foam above the batting before placing the plywood on top.
Attach the fabric to the board by adding a staple every 2 inches with the staple gun. Start by inserting one staple in the center of each side to hold the fabric in place. Check the front to make sure the pattern is still aligned the way you'd like it. Continue stapling and checking the fabric to make sure it is still taught. Trim off the excess fabric and batting about an inch beyond the staple line.
Locate the studs on the wall behind your bed. Attach the bottom part of a flush mount to the wall over the studs, pointing upward. Hold the headboard against the wall and mark the back of the plywood where the interlocking flush mount should be attached. Lay down the headboard and drill the holes for the hardware in the marked location before attaching the flush mount facing down. Mount the headboard with another person's help.