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 are only by intentions, and every person shall have only what he intended. So whoever's emigration was for Allah and His Messenger, his emigration is to Allah and His Messenger; and whoever's emigration was for some worldly gain he would attain, or for a woman he would marry, his emigration is to that for which he emigrated."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 1422