Q: How do I make the proper intention for prayer?
A: The intention (niyah) is a condition of prayer without which prayer is invalid. Because it's location is the heart, it is not voided due to any circumstance.It consists of the determination to perform a specific prayer be it obligatory or voluntary.
If it is an obligatory prayer, the intention must be for the specific prayer e.g. Zuhr, Asr, or a prayer to fulfill an oath. If it is a specific voluntary prayer, the intention must specify that in order to distinguish it from others e.g. tarawih, witr, or ratibah.
It is not necessary to include in the intention the obligatory nature of the prayer as this is included in the specific prayer being offered.
The intention is best made with the opening takbir for prayer but can be made shortly before and must be maintained (by not nullifying it) throughout the prayer.
Source: Sharh al-Muntaha