and why do you think it's inefficient?
there are only a few (mainly cosmetic) things:
i don't like vars put inside strings
include('../'.$config[0].'/themes/'.$config[1].'/loginform.tpl');
you should do stripslashes only after checking [man]get_magic_quotes_gpc[/man]
why do you have mysql compare the username entered and php the password entered?
$sql = 'SELECT userid
FROM '.$db[4]"._users
WHERE username = '".$uName."' AND `password` = '".$uPass."'";
(don't know if the backticks are neccessary here but i think so as password() is a mysql-builtin function)