added comments and inserted a login check for index.php