Well this is totaly from readying other peoples code to to intigrate temeplets all you would need to do is at the beginning of your scirpt add something like
PHP Code:
$templatesused =
and then you add the lines like
PHP Code:
eval("\$headinclude = \"".gettemplate('headinclude')."\";");
as for the members database that is all just a matter or query the database for the right fields which you can figuare out by looking at other peoples code or by looking at the database layout.
EDIT: don't forget the require gobal line. but I believe if all you are using is the members database all you need to do is query the right information but you would have to add the database information and then the connect codes.