Added logout.php
Added additional functionality and fixed a few php errors.