The range selector is interlocked by a solenoid that is activated by the brake switch. Always check that the brake lights come on first.
Have your battery tested and if it's OK check for corrosion in the power distribution path (battery terminals, grounds, under the fuse and relay box...)