The Nikon D40 is "almost" perfect candidate for all beginners. The only thing it lacks, is the in-body autofocus motor. The D40 only autofocuses with lenses branded "AF-S".
If you want access to older (and often, cheaper) autofocus lenses then I would suggest snagging a D70 or D70s used (about $250-350). The newest consumer model with a built-in autofocus motor will be the D90 which cost over $800 for the body alone.
D90 has more megapixel
D90 has 11 autofocus areas, compare to D40's 3.
D90 has a built-in autofocus motor, D40 doesn't.
D90 has a handy top LCD screen that displays all your shooting configuration, D40 doesn't.
D90 also shoots more pictures per second compared to D40.
D90 is bigger and heavier.
D90 has an optional battery grip made by Nikon, D40 doesn't.
D90 performs better in low light (high ISO) compared to D40.
D90 have video option.
D90 has LiveView, D40 doesn't.
The D70 is like a "dumbed down" D90 (which makes sense, since the D90 is two generations newer) with many of the D40's features. It has 5 autofocus area, in-body autofocus motor and top LCD.
I think that's about it..