Question: When I stand up for a prayer I usually get a lot of thoughts and I heard this wasn’t allowed. How do I fix this?
Answer: Bismillah
The perfection of prayer comes from following the Sunnah of the Beloved Prophet, God bless him and give him peace. Outwardly, this means following the Prophetic teachings [with regards to actions]. Inwardly, this means embodying the Prophetic state: having presence with, and remembrance of, Allah Most High.
This has 3 aspects:
1) During prayer.
This is achieved by focusing on what we are saying and what we are doing.
One should know the meaning of what is said, and one should bring to mind why they are praying to begin with.
2) When you begin.
Focus. Gather your thoughts before you step into prayer. Pay attention to your intention. The significant action is not that you are praying, it is that you are praying to ALLAH.
3) Outside of prayer.
Have presence of heart with Allah outside of prayer, and you will have presence within it. Strive to keep your tongue moist with the remembrance of Allah in all that you do.
( Source:- http://seekersguidance.org/ans-blog/2013/11/11/how-to-attain-presence-of-heart-in-prayer/)