Forgetting a Rak'ah in Congregational Prayer

Question
I forgot a rak'ah in the congregational prayer because I was in the women's section, and I didn't realize it until the end of the prayer. I did not conclude with the imam and instead stood up and performed the rak'ah, then I prostrated for forgetfulness. Is my action correct?
Answer
I say, and with God's help: the picture is not clear, and God knows best.
imam icon

Send your question to the smart assistant

If the previous answers are not appropriate, please send your question to the Mufti via