It is narrated from Sayyiduna Umar (may Allah be pleased with him) that indeed the Messenger of Allah (peace and blessings be upon him) said: "All actions depend upon intentions, and for every person is what he intended. So, whoever's migration was for Allah and His Messenger, then his migration is for Allah and His Messenger; and whoever's migration was for worldly gain or to marry a woman, then his migration is for that for which he migrated."
Explanation- This blessed hadith is among the comprehensive statements (jawami‘ al-kalim) of the Noble Prophet sallallahu alayhi wa sallam. It is counted among those ahadith which are the foundation and basis of Islam. In it, it has been explained that all actions depend upon and are based on intention (niyyah). A person will receive the fruit of his intention; if the intention is good, then the fruit will also be good, and if the intention is bad, then the fruit will also be bad. And it should also be remembered that the place of intention is the heart. The resolve of the heart is called intention (niyyah); it has no connection with the tongue. The words uttered by the tongue are not intention, rather they are called statements (qawl).