Narrated 'Umar bin Al-khattab:
I heard Allah's Messenger (PBUH) saying,
"The reward of deeds depends upon the intention and every person will get the reward according to what be has intended.
So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for."
Reference: Sahih Al-Bukhari1