The correctness of prayer depends on the Faith in the Twelve Imams (as). Any prayer without this belief is futile. In fact any amount of prayer without the love for the Ahl-ul-Bayt of the Prophet has negative effects.
Bin Babawiyah narrates from Imam Ja’far As-Sadiq (as) that when a person goes for accounting of his deeds on the Day of Judgement, he will first have to attest his Faith in the Wilayeth of the Imams (as) before he accounts for his Salat (Prayer), Sawm (fasting), Zakat (the tithe) and the Haj.If at the time of his death, a person has faith in the Ahl-ul-Bayt, his compliance with the Furoo al-Deen, the religious practices mentioned here, will be acceptable to Allah.
The Imam (as) also said that Jibrael came to the Prophet (S) and said, “Allah sends you His Greetings and says that He has created the earth and the sky as also the Muqaam al-Ibrahim (the Place of Ibrahim). If a human being worships Him sitting near the Place of Ibrahim, at the Door of the Kaaba, throughout his life, or even from the day the Universe was Created till the Doomsday, with no love for ‘Ali Bin abi Talib (as) in his heart, will be put in the Hell.”
It is also narrated that it was Revealed by Allah to His Prophet (S) even if a person becomes lean like a dried leather water pouch in His Prayer without the love for the Ahl-ul-Bayt, he will not earn an entry to the Heaven.
Imam Zain-ul-’Abidin (as) narrates that the Prophet (S) said that a person who has good deeds in his account equivalent to the good deeds of seventy prophets, and has no love for the Ahl-ul-Bayt, will never be admitted to the Heaven by Allah. The Imam (as) also asked his companions, “Tell me, which place is the most sacred?” The companions said, “The Imam (as) knows the best!” He said that the most sacred place is the Muqam al-Ibrahim. But if a person, with the longevity equal to that of Noah, sits there and prays all his life, and has no belief in our Wilayeth, his prayers will be futile.”
This tradition is accepted by all the schools of thought that, “One who did not recognize the Imam (as) of his time, he died an infidel.” Therefore for every Muslim the knowledge about the Imam is absolutely necessary.