Answered by Shaykh Muhammad ibn Adam al-Kawthari
If one is unable to prevent oneself from coughing or sneezing during prayer or if one is unable to continue praying without coughing or sneezing or if one coughs or sneezes during prayer accidentally and forgot to attempt to restrain oneself, is the prayer invalidated?
Sneezing in Salat does not invalidate the prayer as it is unintentional.
As far as coughing is concerned, it will invalidate the Salat if the cough was without a need and it created the sound of letters. In other words, if one was to cough due to being forced or no sound of letters were uttered, then Salat will not be invalid. However, if one coughed without having the actual need and it created the sound of letters, then Salat will become invalid (See: Tahtawi ala Maraqi al-Falah, P.324).
And Allah knows best
Muhammad ibn Adam al-Kawthari, UK
www.daruliftaa.org