Rulings regarding Prayer- Intention (Niyyah)
Niyyah means that one should intend at the beginning of prayer to perform it for the sake of Allah, and if they perform a prayer with the intention of ostentation or pretention, not only is their prayer invalid but they have also committed an unlawful sin . Even if one performs a prayer for the sake of Allah and people at the same time, their deed is still invalid and considered a grave sin.
Niyyah, however, does not require particular etiquette or a specific utterance. For one to fulfill their intention properly, they should perform their prayers with the intention of seeking nearness (qurbah) to Allah, or complying with Allah's commands, and it is not even necessary for one to mention their intention or make it pass through the heart; rather, for Niyyah to be fulfilled, it is sufficient that if they were asked as to what they’re doing they could answer that they’re performing, for example, the Ẓuhr prayer for the sake of Allah.
However, in addition to seeking Allah's pleasure, the type of prayer to be performed should also be clear in niyyah. For instance, if it is midday, the individual should specify whether they are performing the Ẓuhr prayer or the ʿAṣr prayer, and it would not suffice to solely have the intention of performing a four-rak'ah prayer. The obligatory precaution even demands that one specify whether the prayer is a missed (Qaḍa) or a punctual (Ada') prayer.
After one has made their intention, they must maintain it up to the end of prayer, meaning that if they are so distracted while performing the prayer that they have no idea what they are doing and which prayer they are performing, they will lose their intention and their prayer will be invalidated.