Sheikh Salman al-Oadah
For acts of worship such as prayer, a specific intention of worship is a must.
A proper intention in worship, in fact, is needed in the following matters:
A. The worshipper must intend that this deed is completely and sincerely worship for Allah, because if he intends such an act for others it will be void.
B. The worshipper must have the intention to do the specific act in question, such as having intention to perform the noon prayer (salâh al-zuhr) or the afternoon prayer (salâh al-`asr).
Normal deeds which come under benevolence to others will be rewarded even if the servant did them out of sympathy only, without specifically intending to attain the pleasure of Allah. This shows the greatness of Allah’s favor and His encouragement for people to deal amicably and sympathetically with each other.
Ibn Taymiyah mentioned something similar to this in his book entitled al-Istiqâmah. A number of scholars have concurred with this idea.
However, this subject can be explored in far greater detail.
Source: Islam Today