ok... I have found another way. I tried using the global method but could not seem to be able to get it to work. I am using session variables instead. That way, I do need to use session_start() before calling the function, nor do I need to declare $username or $password before the function is called.
Thanks for the suggestion anyway, thorpe.