For a missing flat button on a woven school shirt, match the spare to the buttonhole before sewing. Use the old thread marks to locate the button and check the shirt closes without a diagonal pull across the placket.
Check the button, hole and fabric
Compare the spare with a button from the same shirt: diameter, thickness, colour and number of holes. Pass it through the buttonhole gently. The button needs enough clearance under it for the opposite placket to sit comfortably. Inspect the spot where it came off. If the original button pulled a small hole in the fabric, reinforce that area first instead of sewing into the torn edge.
Position the button on the original spot
Close the neighbouring buttons and line up the two plackets. Mark the centre where the buttonhole meets the fabric below. Remove loose thread and take a small anchoring stitch. For a four-hole button, copy the thread pattern of the neighbouring ones. A thin spacer, such as a needle laid across the face of the button, can keep a little room between the button and the cloth as you sew. The required gap depends on the thickness of the placket.
Secure the stitch bundle
Make several controlled passes through the holes and fabric. Stop before the thread builds up enough to obstruct the buttonhole. Remove the spacer and, if you left a gap, wrap thread around the stitches below the button to support that short thread shank. Secure the end on the inside. Keep the back stitches tidy so they do not catch against the skin.
Try it with the shirt on
Button and unbutton the shirt a few times. Check that the button sits flat when closed and that the placket does not pull into a ridge. If it wobbles or the buttonhole stretches when opened, reconsider the button size or the amount of clearance. A blazer button with a metal or moulded loop uses a different attachment; see the shank-button guide.