If a person makes a mistake in adhkaar that are obligatory in the prayer, such as the dhikr when sitting between the two prostrations and in the tashahhud – the first part of it – what is the ruling on his prayer if he forgot or was unaware (that it is obligatory)? What about previous prayers in which he made this mistake and does he have t o repeat them?.
The dhikr that comes between the two prostrations is one of the Sunnahs of the prayer and is not obligatory. This has been discussed previously in the answer to question no. 130981
Based on that, if a person omits it deliberately or out of ignorance, that does not render his prayer invalid and he does not have to do anything. If he forgot it although he usually does it, it is mustahabb for him to do the two prostrations of forgetfulness before the salaam.
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) said: If a person omits one of the mustahabb words or actions out of forgetfulness and he usually does it, then it is prescribed for him to prostrate (the prostration of forgetfulness) to make up for this omission that affected the perfection of the prayer but was not an omission of something obligatory, because of the general meaning of the words of the Prophet (blessings and peace of Allah be upon him) in the hadeeth, “For every mistake there are two prostrations”– narrated by Abu Dawood; it is a hasan hadeeth. In Saheeh Muslim it says: “If one of you forgets, let him prostrate twice.” As this is general in meaning, if he omits a Sunnah that he does not usually do, then it is not Sunnah for him to prostrate, because it never occurred to him to do it.
End quote from ash-Sharh al-Mumti‘ ‘ala Zaad al-Mustaqni‘, 3/333, 334
The first Tashahhud is one of the obligatory parts of the prayer although it is not one of the pillars or essential parts, as was explained previously in the answer to question no. 34570
If someone omits this obligatory part deliberately, his prayer is rendered invalid, as you will see in the answer to question no. 9897. If someone omits it because he forgot, then he has to do the prostration of forgetfulness before the salaam. If someone omits it because he is unaware of the ruling on it, he does not have to do anything, because the one who is unaware is excused.
The evidence for the obligatory parts of the prayer being waived in the case of forgetfulness, and that the prostration of forgetfulness is required in this case, is the report narrated by al-Bukhaari (795) and Muslim (570) from ‘Abdullah ibn Buhaynah (may Allah be pleased with him), according to which the Prophet (blessings and peace of Allah be upon him) led them in praying Zuhr, then he stood up after the first two rak‘ahs and did not sit, and the people got up with him. When he had finished the prayer and the people were waiting for him to say the tasleem, he said takbeer whilst sitting and prostrated twice before saying the salaam, then he said the salaam.
Ibn Qudaamah (may Allah have mercy on him) said, concerning one who omitted the obligatory part deliberately: His prayer is rendered invalid. But if he omitted it by mistake, he should do the prostration of forgetfulness before he says the salaam, because of the report narrated by ‘Abdullah ibn Maalik ibn Buhaynah -- and he quoted the hadeeth. Thus this idea is proven, and by analogy we apply the same principle to all the obligatory parts (of the prayer).
End quote from al-Kaafi, 1/273
And Allah knows best.