Sayyiduna al-Mughirah bin Shu'bah (may Allah be pleased with him) narrates that the Messenger of Allah (peace and blessings be upon him) said: "When the imam stands up after two rak'ahs (forgetfully, without reciting the tashahhud), then if he remembers before he has stood fully upright, let him sit down; and if he has stood fully upright, let him not sit, and let him perform the two prostrations of forgetfulness."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3844