http://ets.dhs.org/admin/
That's a small project I threw together. The source subdir. has some login stuff that you may find useful...or, you could download one of the hundreds of open source projects that have login scripts and look at how they do it.