Which 19th century U.S. president was elected after a sex scandal that claimed he fathered a child out of wedlock?

Which 19th century U.S. president was elected after a sex scandal that claimed he fathered a child out of wedlock?