Riyad as-Salihin, Book 6, Hadith 859 (In-Book)

Abu Hurairah (May Allah be pleased with him)reported in the Hadith in respect of the person who was at fault in performing his Salat (prayer): He came to the Prophet and greeted him. The Prophet responded to the greeting and said, "Go back and repeat your Salat because you have not performed the Salat (properly).'' He again performed Salat as he had prayed before and came to the Prophet and greeted him. The Prophet responded to the greetings (and repeated his words to him). This act of repeating (the Salat and the Salam) was done thrice. [Al-Bukhari and Muslim].

عن أبي هريرة رضي الله عنه في حديث المسيء صلاته أنه جاء فصلى، ثم جاء النبي صلى الله عليه وسلم، فسلم عليه، فرد عليه السلام، فقال‏:‏ ‏ "‏ارجع فصلِ، فإنك لم تصلِ‏" ‏ فرجع فصلى، ثم جاء فسلم على النبي صلى الله عليه وسلم، حتى فعل ذلك ثلاث مرات” ‏(‏‏(‏متفق عليه‏)‏‏)‏

sunnah.com