Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) said: I heard the Messenger of Allah (peace and blessings be upon him) saying: "Actions depend on intentions, and a person shall have only what he intended. So whoever's emigration is to Allah, the Mighty and Majestic, his emigration is for Allah and His Messenger; and whoever's emigration is for some worldly gain that he may obtain, or for a woman that he may marry, his emigration is for that to which he emigrated."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / 8992