i'm not sure i understand, based on your code. If you are passing the vars to checkpoint.php, then just put the login code in checkpoint.php - it doesn't particularly have to be inside a function...
if you use a function in another file, just [man]include[/man] that function, then call the function i.e. login($username, $password).
let me know if this is not what you're after...?