On the authority of Omar bin Al-Khattab, who said : I heared the messenger of Allah salla Allah u alihi wa sallam say :
"Actions are but by intention and every man shall have but that which he intended. Thus he whose migration was for Allah and His messenger, his migration was for Allah and His messenger, and he whose migration was to achieve some worldly benefit or to take some woman in marriage, his migration was for that for which he migrated."