Flange Support Bracket for Rotted Floors
If the floor is too spongy to screw down a toilet flange, attach a flange support bracket to the floor and then secure the toilet flange to that. This fix will work only if the majority of the floor under the toilet is solid. Probe the floor by poking it with a screwdriver. If more than an inch or so around the flange is rotten, you'll need to repair the floor itself.
The bracket shown here is part of the QUIK-FIX Wobbly Toilet Repair Kit. You can find the kit at some home centers, plumbing suppliers or online. It will also work over holes in the floor that have been cut a bit too large.