You really don't need a script for that. You can just use .htaccess control.
That only works for one or two users at a time. A whole lot of users at once and the .htpasswd file becomes unmanagably large.
What Sander needs is something more along the lines of a MySQL-backend login system. It's not that hard to code one, but off hand I don't have anything suitable short of ripping the authentication code out of my own site and using that- I did a hashed password solution using session cookies for reauthentication between pages.