Gary is right, they are different.
Depending on a person's accent (and how the word is being used grammatically), "to" can sounds like /d/ in some cases, or it can sound like /t/, or like "too" (the same pronunciation as the number "two").
The word "the" should always be pronounced with a voiced /th/ sound (except in a few specific, non-standard accents of English). To make the /th/ sound, your tongue should touch the back of your upper teeth -- not the roof of the mouth, which makes the sound /d/.