I want to tie-in to my UBBT database for a membership system. So, I need a simple login script that will query the UBBT database to check for a matching username/password combination. If it exists, the script should then check to make sure the user is not banned. If everything is okay, the script should set a cookie and redirect the user to the page they came from. I'd like to have the option of including a hidden form input variable that would specify a URL where the user should be redirected instead of the current page.
I have a working script that was written in perl for a tie-in to ubb.classic, but I don't know how to convert it to php.
BTW: I'd like the script to be well-commented so I can change things later if necessary.