The World Federation One Stop Fiqh

Ruling 997

If a person recites Sūrat al-Ḥamd in the last two rakʿahs of prayers thinking that he is performing the first two rakʿahs, or if one recites it in the first two rakʿahs supposing that he is performing the last two rakʿahs, his prayer is valid whether he realises this before or after rukūʿ.