All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
Whoever performs the prayer of Thuhr after its time elapsed with the intention of performing it on time then his prayer is correct if he did not know that its prescribed fixed time had expired. However, if he knew that its prescribed fixed time was over and intended to perform it on time, then his prayer is void as he is playing (with his prayer); a group of scholars stated this opinion, among whom are An-Nawawi and Ibn Al-Muflih, who said: 'It is valid to make up for a missed prayer with the intention of praying on time and vice-versa if later one discovers the contrary of what he believed in; this view is mentioned by the scholars of the Hanbali school. However, it is not valid to make up for a missed prayer with the intention of praying it on time and vice-versa if one knows the contrary [for instance it is not acceptable to make up for Thuhr prayer when one knows that its time is not yet over, rather he should intend to pray it on time, and it is not acceptable to intend to pray on time when one knows that the time of the prayer is over].'
Therefore, if you knew that the time of the prayer elapsed and you performed the prayer with the intention of performing the prayer on time, then you are obliged to make it up, but if you did not know that its time elapsed and you performed the prayer with the intention of performing it on time, then your prayer is valid and you are not obliged to make it up Even if you neither intended to perform the prayer on time nor did you intend to make it up, then your prayer is valid that is because the intention of performing the prayer on time and the intention of making up a missed prayer is a Sunnah and not an obligation, so if someone fails to do so [intend to which kind of prayer he wishes to perform] then his prayer is correct.
Allaah Knows best.