Database functionality and basic error checking for pages