Apologies if this has been asked somewhere else. I did search, but it's a bite of a niche question I think.
I currently use a simple bit of GOTO logic to skip the rendering of certain HTML elements, based on a users permissions. I want to know if there is anything fundamentally wrong with this approach and if so, what is the preferred alternative?
One of the main reasons I'm asking, is I'm slowly migrating my existing code to a more MVC approach, and I'm not sure GOTO is particularly compatible with MVC.
Many thanks for any answers.
For example:
<?php
$isUserAdmin = 0;
?>
<html>
<?php if(!$isUserAdmin) {goto notAdmin;} ?>
<a href="/admin.php">Admin Control Panel</a>
<?php notAdmin: ?>
<a href="/vieworders.php">View Orders</a>
</html>
P.S - On pages I want to explicitly restrict, there is an actual explicit check which will redirect them.
source https://stackoverflow.com/questions/67797336/php-using-goto-to-skip-rendering-of-html
No comments:
Post a Comment