Complete what you forgot if the time is short
Question

                I prayed Zuhr, and after that I remembered that I had only prayed three rak’ahs. Should I pray the fourth and do sujood al-sahw (prostration of forgetfulness), or should I repeat the whole prayer?
Praise be to Allah.
    When a worshipper omits one or more rak’ahs of his prayer, 
    then he remembers when he is still in the place where he prayed or in the 
    mosque, and only a short time has elapsed, such as five minutes, then he 
    should complete the prayer by doing what he omitted, then he should say the 
    salaam and do the prostration of forgetfulness, then say the salaam again. 
    But if he does not remember until after a long time has passed, such as half 
    an hour, or a long time after leaving the mosque, then he should repeat the 
    entire prayer and consider the first invalid, because there was no 
    continuity between the rak’ahs.