Or get a board and put it at the bottom to stop the mattress from moving.
How to fill gap between mattress and bed frame.
Block the gap when a new mattress is just not in the budget consider bridging the gap at least until you can afford a new mattress.
To make a cover for storage.
Place the structure between the mattress and the foot board and enjoy.
Secure the two longer pieces to the remaining short piece with 2 1 2 wood screws.
Add the boxspring and mattress back to the frame and push them flush with the headboard.
Adjust the bed frame so that it is wider than the headboard by unhooking it at the middle and widening the frame.
Cover it with fabric or an old quilt or sheet.
Put the pillows on that area which now makes the bed longer.
Push the frame back against the headboard.
Place the hook into the next available groove.
Then attach the right half to the left half using either pocket hole screws or angle brackets.