Foreclosure happens when you can no longer make your mortgage payments and the bank must take possession of the home to compensate themselves for the loss. While a foreclosure can put a large blemish on your credit and make it difficult to get another home loan for a few years, it is not a completely devestating occurance when it comes to your credit score. You'll experience a down turn that will stick with you, yes, but eventually, you will be able to rebound your credit and buy another home some day. The foreclosure will remain on your credit for seven years. Even with the foreclosure mark on your credit file, depending on the lender, you may still be able to get other lines of credit for credit cards and auto loans.
Bankruptcy occurs when you file to have all your debt charged off. Though this figuratively wipes the slate clean for you to start over, this blemish is much larger and lasts 10 years, instead of the traditional seven. Though regulations have made it harder for people to file for bankruptcy, people still do it. Depending on the severity of your financial situation, it may be the best option, but it is important to consider other outlets before deciding to file. With a bankrutpcy on your record, it will make it harder to get financing or credit for anything at all.
The short answer is, yes. Bankruptcy is worse on your credit than foreclosure because it shows an inability to pay all debt, whereas the foreclose shows inability to pay one debt. While both are not a good move for the credit score, bankruptcy is the worst one, becasue it will make the credit score go down an average of 300 points. A foreclosure will make the credit score go gown about 150.
In the long run however, a bankruptcy allows you to "start over" whereas a foreclosure does nothing about other debt. If you're not careful about keeping the other credit lines you have under control, even after the foreclosure drops from the report, the score may not improve because of your inability to pay those debts in the meantime, which made lead you to bankruptcy anyway.
The bottom line is, be careful. Spend wisely, budget accordingly, and most importantly, build up savings. Savings will help you continue to make mortgage payments and avoid foreclosure if you or your loved one loses a job, and will keep you off the track for bankruptcy because you won't have to over extend credit lines to survive.