In that case, you could probably just let Apache handle the authentication by using an htaccess file in the directory containing your script. I believe that should work, unless I'm missing something.
__________ The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
- Terry Pratchett