WARNING: bad language inside!
I'd like to explain the difference between this two Spanish idioms because I've been in several situations with Spanish and foreign friends in which foreign guys (especially if they know some Spanish or if they learn it in Latin America) though that the Spanish guys were insulting them. both of them are really common in Spain (not in LatAm, where "de puta madre" would be not very well understood), in informal contexts of course, but one of them is good and the other is not...
De puta madre: you say this to express your joy, satisfaction or agreement. A free translation would be "Fucking great!"
-¿Cómo estás? -De puta madre! [-How are you? -Very well!]
-La tortilla estaba de puta madre. [-The omelette was really awesome.]
-Nos vemos a las ocho. -De puta madre. [-We'll see at eight. -Ok, great.]
Tu puta madre: this is a real insult, referred to the job of the other person's mother. A free but in this case accurate translation would be "Fuck your mother!"
-Eres idiota. -Tu puta madre! [-You're an idiot -Fuck your mother!]
-Me cago en tu puta madre. [Fuck your mother.]
-El dinero te lo va a dar tu puta madre. [Ask your fucking mother for the money.]