Praise be to Allah.
If a person forgets takbeerat al-ihraam or is not sure whether he did it or not, he should say takbeer straight away, and then do whatever he had caught up with after the takbeer. If he says takbeer after having missed the first rak’ah with the imam, he should regard himself as having missed the first rak’ah and make it up after the imam says the tasleem. If he repeats the takbeer in the third rak’ah he should regard himself as having missed two rak'ahs and should do two rak’ahs after the imam says the salaam. This applies for one who is not affected by waswaas. But if he is suffering from waswaas, he should regard himself as having said the takbeer at the beginning of the prayer and he should not make up anything, in order to annoy the Shaytaan and fight him and his whispers. Praise be to Allaah.