All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
What we understood from the question is that your bleeding lasted for more than 15 days; therefore, your situation is one of the following cases:
1- If you have a menstrual period whose time of occurrence and number of days are known – six or seven days at the beginning of the month, for example – before you had this bleeding, then you should refrain from praying during this period at its regular time, and you should consider it as menses, and then you should perform Ghusl and whatever bleeding you have after this, you should consider it as bleeding outside the monthly period. The evidence for this is that ‘Aa’ishah narrated that Umm Habeebah Bint Jahsh complained to the Prophet about bleeding, and the Prophet said to her: "Refrain from praying (for a period of time) equal to the period of time that your menstruation holds you back and then perform Ghusl…” [Muslim]
2- If you have a monthly menses whose number of days is known – six days, for example – but you do not remember exactly whether it is at the beginning of the month, at the middle of the month, or at the end of the month, then in this case, you should refrain from praying for this period at the beginning of the month, according to the well-known opinion of the Hanbali School. Al-Buhooti said: “If she knows the number of its days, i.e. the days of her menses, but she forgot the time of its occurrence, like if she does not know whether she has menses at the beginning of the month, at the middle of the month, or at the end of the month, then she should refrain from praying during the same number of days (of her menses) at the beginning of each lunar month as the Prophet considered the menses of Hamnah Bint Jahsh at the beginning of the month, and ordered her to pray during the remaining days of the month. This is also because the blood of menses is a natural matter while bleeding outside the monthly menses is something abnormal, so if she sees it (i.e. the blood at the beginning of the month), she has to consider it as menses.”
3- If you know the time of the occurrence of your previous menses but you forgot for how many days it was, then you should act contrarily to the second situation. In which case, you should refrain from praying for the usual duration of most women's periods – six or seven days – at the time of your monthly menses in the month, and then you should perform Ghusl and consider any bleeding that exceeds this period as bleeding outside the monthly menses. Al-Buhooti said: “If she knows the exact time of the occurrence of her menses, like if she knows that she has menses during the second 10 days of the month but she forgot the number of days during which she has menses, then she should refrain from praying and fasting during this time-period for the usual duration of most women's menstrual periods, either six days or seven days…”
4- If you do not have an exact monthly time of your period, in this case, you should refrain from praying for the usual duration of most women's periods, like the third case, but this should be at the beginning of the month.
However, in all the previous cases where we mentioned that you are considered as having your period, you should refrain from praying, fasting and sexual intercourse with your husband, and in the cases where you are considered as having bleeding outside your monthly periods, you should pray and fast and it is permissible for your husband to have sexual intercourse with you. In this case, you should perform ablution for every prayer after its prescribed fixed time begins, and then the bleeding discharges have no effect even during the prayer.
For more benefit on the rulings of bleeding outside the monthly periods, please refer to Fatwa 83908, and also refer to Fataawa 91444, 98693 and 128778.
Allaah Knows best.