how to do stop a foreclosure from occurring?

If any of you were unfortunately in a forclosure situation, could you give me any insight as to what you did to resolve your problems? Thanks so much

There are two ways to stop a foreclosure, one is to pay what is owed, and the other is to file bankruptcy.