To enter in cheat codes, first press T, then enter in your desired code.
This trick will require you to reach the end of E4M4, "Crystal Lake". In the cavern with the end level switch after defeating the queen spider (or luring it into the water where it can't get back out, whichever works), use the napalm cannon or dynamite to the wall on the right side. This will reveal the red exit switch which will take you to E4M9, "Mall Of The Dead".
To get to the secret level in episode one of Blood, you must be in map E1M4, ''Dark Carnival''. At the end of the level, after the bridge explodes, instead of jumping down into the water to get to the exit, jump to the other side to the ledge, using the pillars of the bridge. Then, blow up the crack in the wall and jump into the little pond. Swim to the surface to end up in a small cave. Ahead of you are some switches on a big stone. Push the skull switches to this combo: Dagger, Eye, Moon. And you're on your way!