Umar ibn Al-Khattab reported: The Messenger of Allah, peace and blessings be upon him, said:
Verily, deeds are only with intentions. Verily, every person will have only what they intended. So whoever emigrated to Allah and His Messenger, then his emigration is for Allah and His Messenger. Whoever emigrated to get something in the world or to marry a woman, then his emigration is for whatever he emigrated for.
Source: Sahih Bukhari 54, Grade: Muttafaqun Alayhi