Is it permissible for someone who has forgotten to mention the supplication pertaining to answering the call of nature to say it while in the toilet?
It is disliked for a Muslim to mention Allah while in the toilet, but he/she may recall the supplication in his/her head without uttering it; that is in case he/she had forgotten mentioning it before entering the toilet.
What is the ruling on someone who vowed to fast for two consecutive months, but failed to do so?
He is obliged to fulfill his vow by fasting for two consecutive months, but if he fails to do so then, it remains a debt on him until he either fulfills his vow, or dies. In case of his death, his guardian is supposed to fast on his behalf, or donate food from his estate in return for fasting, but if the guardian fails to do so then, it is all in the Hands of Allah.
What is the ruling on a person in a state of major impurity (junub) or a menstruating woman (ha'id) reciting the Quran from memory?
It is not permissible for a menstruating woman, a postpartum woman, or a person in a state of major impurity to recite anything from the Quran, whether from memory, from the Quran, from a phone, or a computer. It is also not permissible for them to touch the Quran, based on what was reported from Ali bin Abi Talib that the Prophet (peace be upon him) was not prevented from anything regarding the Quran except major impurity (janabah). (Reported by al-Tirmidhi who said it is a hasan sahih hadith). Menstruation and postpartum bleeding are analogous to major impurity (janabah) as they are all major impurities (hadath akbar).
For those mentioned, it is permissible to mention Allah and supplicate even with verses from the Quran, provided they do not intend them as recitation of the Quran, but intend them as remembrance (dhikr) or supplication (du'a). And Allah the Almighty knows best.
Is it permissible for one to masturbate in order not to commit fornication?
This is called committing the milder of the two evils such as eating a carcass in fear of death, and this happens when committing fornication is very likely to occur.