Here's what I do. I create a directory (which I typically call lib)outside web directory that has all my common scripts. Then within the files that need to call the scripts I put:
include("/path/to/lib/somescript.php")
The path needs to be relative to your home directory not your web directory. Any HTML within the loaded scripts will be relative to the page they're being included in
I usually go further and define a LIB constant (that's the path to the lib directory) in a config page that gets called with every page. That way I can simply 'include(LIB."/somescript.php")' and if I ever move the lib directory I just redifine the constant.
For a login process I do something like this within an index.php page (this is pseudo code):
<?php
if(!$loggedin)
{
include("/path/to/script/login.php");
if(!ValidateUser($username,$password)
{
include("/path/to/script/badlogin.php");
}
else
{
include("/path/to/script/welcome.php");
}
}
?>