"Istikhara" means to seek goodness from Allah (Exalted is He), meaning when one intends to do an important task they do istikhara before the task. The one who does the istikhara is as if they request Allah Almighty that, O the Knower of Unseen (Exalted is He) guide me if this task is better for me or not?
According to Bukhari, Volume 2, Book 21, Number 263:
Narrated Jabir bin 'Abdullah :The Prophet (Sallal Laho Alaihi Wasallam) used to teach us the way of doing Istikhara, in all matters as he taught us the Suras of the Quran. He said, "If anyone of you thinks of doing any job he should offer a two Rakat prayer other than the compulsory ones and say (after the prayer):
TO PERFORM ISTIKHARA:
First pray Two Cycles (raka') of ritual Prayer (nafil) such that in the first raka' after Surah Fatiha (Allhamd ) recite Surah al-Kafirun (Chapter 109) and in the second raka' after Fatiha (Allhamd ) recite Surah al-Ikhlas (Chapter 112). After finishing prayer recite this (supplication/dua'): Dua in Arabic Text above.
TRANSLATION: "O Allah! I seek goodness from Your Knowledge and with Your Power (and Might) I seek strength, and I ask from You Your Great Blessings, because You have the Power and I do not have the power. You Know everything and I do not know, and You have knowledge of the unseen. Oh Allah! If in Your Knowledge this action ------------------------------------------------ (which I intend to do) is better for my religion and faith, for my life and end [death], for here [in this world] and the hereafter then make it destined for me and make it easy for me and then add blessings [baraka'] in it, for me. O Allah! In Your Knowledge if this action is bad for me, bad for my religion and faith, for my life and end [death], for here [in this world] and the hereafter then turn it away from me and turn me away from it and whatever is better for me, ordain [destine] that for me and then make me satisfied with it."
How many times?
It depends. Sometimes it takes only once to get the answer and sometimes it takes longer. It is better to do istakhara seven (7) times. If you have received an answer as explained in the section below, stop doing istikhara. You do not have to continue to do isitkhara for 7 days. It is better that right after reciting the supplication, given above, sleep with ablution (people who cannot keep the ablution for longer times due to health problems do not have to worry about ablution before falling asleep) facing the direction of the Qibla (facing the Qibla is not required but it is a Sunnat of our beloved Prophet Peace Be Upon Him). It is better to recite salutations (durood/ salawat) on the Prophet Allah's Grace and Peace be upon him before and after the above Dua (supplication).
If in the dream one sees whiteness (means any thing white in color, for example: milk, white paper, white sky, white clothes, white light etc.) or greenness (means any thing green in color, for example: grass, plants, trees, green clothes, green light etc.) then understand that this task is better and if one sees redness (means any thing red in color, for example: blood, red clothing, red fruit, red light etc.) or blackness (means any thing black in color, for example: black water, black light, black clothings, black sky, black wall etc. ) then understand it is bad and avoid it.
If do not remember any dream or do not see any colors then follow your heart. Whatever intention grows stronger in your heart regarding your targated work follow it after seven days of Istakhara.