Made the system less complex and reduced the code size

Made a `db()` and `query()` function to make future expansion easier. Reduced the amount of code it took to write the system.
Does using empty() prevent both a PHP notice if the value isn't set AND prevent against calling sendmessage on "" values?