How to replace a door frame
If your door frame got damaged, you can consider repairing it or replacing it. Assessing the damage is very important.
Sagging aluminum storm door frame can be repaired using a turnbuckle, some wire and screws to shore up the affected area.
You can handle small areas of rotten wood. You need to sand them and then apply some treatment and paint. But if the sections are large, then you will most likely have to replace the door frame.
Loose frames can be repaired with some extra screws and nails. Also take a look to the latch and repair it if necessary. If you cannot repair the frame, then replace it. It will save you more money than trying to fix it each time.