Hello, anyone know how to deal with errors which occur from included files? as passing the error to a root file. Here is the situation: database files are usually .inc or .inc.php files outside of the root for security purposes. I keep all of my code outside of the root. Files within my root are setup to include files outside of the root based upon circumstances or actions.
login is handled from an index.php which checks to see if a user is logged in or not. If user is logged in, include welcome page, else include login page. If request method == post and logout button clicked, then logout/end session. if request method== post and button login clicked, then include login file which checks csrf token and other credentials. If all is well, then include database login file.
i made a token expired error which works fine inside of the login page. The error is displayed in the index file when the token has expired. However, if i set a loginerror in the database login file when the username and password does not match, the error is not displayed on the index page. I had to set an error in the database loginfile, then use an if statement to set a different login error, which then displays on the index page. However, if both events occur, only one error is displayed.
I think that this has to do with scope. Thus, i am asking how should i setup my error handling for nested files? I’ve tried searching google but i can only find the opposite: how to catch errors when files to be included are not included instead of how to pass errors from included files to the calling file.