If he is made bankrupt all his assets are at risk.
Normally, secured lenders rely on their security (i.e. the property their debt is secured on) & do not prove in the bankruptcy. But the Official Receiver in effect becomes the owner of all the bankrupt's property and can look to sell it to realise the equity for the creditors who have proved in the bankruptcy. If it was sold at a price which realised enough to pay off the first mortgage and your second charge then you would be OK, because these rank above the OR's interest.
The OR would not usually be interested in selling unless there was going to be some equity available to creditors, so you should be OK unless something went wrong in the sale process and the property was sold for less than the amount of your charge and the first mortgage.
You could get more info. on this from Insolvency Service website - or go from there to their information helpline or e-mail service.
Apart from the bankruptcy issue, you also need to consider how long it will be before you want to get your money back, what will happen if it is not repaid when you want it, what interest you will get etc. (In principle you can go to Court for an order for sale if the borrower breaks the agreement.) All this needs to be set out in a proper legal document (in effect, a second mortgage). You also need to satisfy yourself that there really is sufficient equity in the property to give you comfort, even if house prices decline further.
Consider that this friend is clearly, from what you say, in a bad way financially already - is it really wise to lend him a substantial amount, even with some security? It might all work out OK, or you could have an awful lot of hassle for a long time to get your money back.