Hadith.1030 - Imam Jafar ibn Muhammad Al-Sadiq عليه السلام said:
"No one misses a prayer who truly desires to pray. The prayer of the day does not miss until the sun sets, and the prayer of the night does not miss until dawn breaks."
This applies to the person who is forced, ill, or forgetful.
If you forget to pray Maghrib and Isha, and remember them before dawn, pray both if there is still time. If you fear one of them will be missed, begin with Isha. If you remember them after Fajr, pray Fajr first, then Maghrib, then Isha before sunrise. If you miss Fajr until the sun rises, pray two rak'ahs for the missed prayer, then perform Fajr.
If you forget the tashahhud (testification) in the second rak'ah and remember it in the third, pause and sit for the tashahhud as long as you have not yet bowed. If you remember after bowing, continue the prayer, and when you finish, perform two prostrations of forgetfulness and recite the missed tashahhud during them.
If you raise your head from the second sajdah in the fourth rak'ah and then break your wudu, if you have said the shahada (testification), your prayer is complete. If you have not yet said it, your prayer is invalid; you must perform wudu again and return to your place, then perform the tashahhud.
If you forget the tashahhud or the Tasleem (salutation) and realize it after you have moved from your prayer mat, face the Qiblah whether standing or sitting, then recite the tashahhud and Tasleem.
If someone is certain that they prayed six rak'ahs, they should repeat the prayer. If someone is unsure how many rak'ahs they prayed, and their doubt does not settle on any particular number, they should repeat the prayer.
If a man prays next to another and mistakenly stands on his left, but later realizes while in prayer, he should turn to his right.
If someone needs to perform prostrations of forgetfulness but forgets to do so, they should perform them whenever they remember.
If a person joins a group in prayer thinking it is the first rak'ah, but it is Asr, they should make it the first rak'ah and complete Asr after. Similarly, if someone stands in a prayer mistakenly thinking it is a voluntary prayer but later realizes it is obligatory, their prayer is valid as it began.
It is permissible for someone to pray Dhuhr behind someone praying Asr, but it is not permissible to pray Asr behind someone praying Dhuhr unless they mistakenly think it is Asr, then they pray Asr with him. This will count as their Asr prayer.