edit
An argument of the form 'If P then Q; Q; therefore P' is affirming the consequent. It is a fallacy and is invalid.