Post hoc ergo propter hoc (Latin: 'after this, therefore because of this') is an informal fallacy that states: "Since event Y followed event X, event Y must have been caused by event X." It is often shortened simply to post hoc fallacy. A logical fallacy of the questionable cause variety, it is subtly different from the fallacy cum hoc ergo propter hoc ('with this, therefore because of this'), in which two events occur simultaneously or the chronological ordering is insignificant or unknown. Post hoc is a logical fallacy in which one event seems to be the cause of a later event because it occurred earlier. 
Post hoc is a particularly tempting error because correlation sometimes appears to suggest causality. The fallacy lies in a conclusion based solely on the order of events, rather than taking into account other factors potentially responsible for the result that might rule out the connection.
A simple example is "the rooster crows immediately before sunrise; therefore the rooster causes the sun to rise."
The form of the post hoc fallacy is expressed as follows:
When B is undesirable, this pattern is often combined with the formal fallacy of denying the antecedent, assuming the logical inverse holds: Avoiding A will prevent B.