I'm trying to achieve something I can't wrap my mind around. The thing is that when a specific user is logged, I store in session the user and that he is logged.
Before telling me yes, I know this isn't best practice but the purpose of this page is internal only and there is no possibility to be hacked or so because you can only access it internally.
Anyway, the point is that there are some editable fields in a table which should be editable only by admin but that should only be seen by the rest.
To achieve the editable table I used datatables library together with some ajax and JQuery.
I can't think of a method to restrict editing when the logged user is not admin other than:
var logged = <?php echo $_SESSION['logged_user'];?>;
if (logged=='admin') {
// action here
}
Do you know a better method or easier to understand? Thank you very much!
var logged = <?php echo $_SESSION['logged_user'];?>;should bevar logged = '<?php echo $_SESSION['logged_user'];?>';first of all..