Hey buddy,
A friend edited your version for me and I think you might like this, so I post it for you;
Code:
// Additions: //
// - Allow only users from specific groups //
// - Return to the wanted page after successfull logon (redirect) //
// - Set the databasename using $DBNAME //
// - connect.php is no longer needed! //
Also, he wrote a short installation instruction.
Bytheway: It works great now!