If a man a woman commit adultery or fornication and she becomes pregnant, if they marry while she is pregnant is that marriage valid? If not, what should they do now? And what rights does that child have on the man?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If one commits Zina (fornication or adultery) with a woman and she becomes pregnant, then it is forbidden for him to marry her except with two conditions.
Firstly, they both must make sincere repentance.
Secondly, marrying her is permissible only after she gives birth, since mixing the sperm of marriage with the sperm of Zina is forbidden. The Prophet said: “A pregnant woman will not be copulated with till she gives birth.” [Abu Daawood and al-Haakim who classified it as Saheeh]
If one marries the woman who became pregnant after having illegal sex with him before giving birth, then the marriage is invalid. Therefore, the marriage contract has to be renewed in the presence of her guardian and two trustworthy witnesses. If they do not renew the marriage contract, then, having sexual intercourse with each other is considered Zina.
As for the child of Zina, it takes its mother's name (only) and inherits from her. If it is a male, he is considered a Mahram for her.
However, the child does not have any legal relation with his biological father [i.e. with the fornicator or adulterer].
If this man and woman are married according to the Sharee’ah, the child would become the man's stepson/or stepdaughter, and the ruling pertaining to stepchildren applies.
Allah knows best.
You can search for fatwa through many choices