On the top of the file I want to check the user rights, e.g. if logged in, if user has access to the page, what content is visible to them, if the content was published by the user themselves, if all necessary parameters have been passed (e.g. POST
-vars) etc.
So, the question was, what would you suggest is the best way (that the code remains readable and understandable, is not too specific for a special page so that it can be implemented on every page, performance as many checks need a database query etc.)
The reason I am asking is, because right now I am doing sth like this:
if($logged_in!=1) {$error="err1";}
else {
if(...) {...}
else {...}
}
So, basically that if one check returns acces denied the code won't go through all other if
s but break immediately. I do not use exit
or die
because I do want to show the page (without content but an error-box), so if I used exit
or die
it would not display any other code below...
What would you suggest to do?
Thank you very much for your help.