Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
How should I hide admin buttons?

I am making a classroom web app with php for a university project. I have the classes displayed on the home page and for example I want to display a delete button if the user who's logged in is a teacher, something like this:

<?
if($_SESSION['userType'] == 'Teacher') {
    //Show
}
if(S_SESSION['userType'] == 'Student') {
    //Hide
}
?>

But my problem is that I'm getting the class elements with ajax, looping over them and adding them to the page using innerHtml. So the only way I can think of is to add a variable in js indicating if the user is a teacher and then I could add a button to the html in js.

But after reading other similar questions I learned that this shouldn't be done client side as it could get hacked. Im new to web programming and I can't figure out how to do this so any help or advice is greatly appreciated

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You must do the verification both on frontend and backend. You can never rely on client side information, so use front end to draw or not the sensitive buttons, but use backend to check if the authenticated user can or cannot do that action.

about 4 years ago · Juan Pablo Isaza Report

0

Just Use some like that on your html file:

<?php
    if($_SESSION['userType'] == 'Teacher') {
        //Show
        ?>
            <button>Delete</button>
        <?php
    }
?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!