Alqamah bin Waqqas (may Allah have mercy on him) said: I heard Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) say on the pulpit: I heard the Noble Messenger (peace and blessings be upon him) saying: "Deeds depend on intention, and indeed a person has only what he intends. So whoever's emigration is to Allah and His Messenger, his emigration is to Allah and His Messenger; and whoever's emigration is for worldly gain or a woman, his emigration is for that for which he emigrated."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الزكاة / 7370