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

385
Views
How to hide buttons based on your "job"?

I am creating an app and I want that the buttons appear based on your $job. There are 4 jobs, which are all in mysql databases:

  1. student
  2. teacher
  3. staff
  4. principal,

The signup button can only be seen by teacher, staff and principal.

But I don't know how to do it.

Here is my code:

<?php
   session_start();

   include("connection.php");
   include("functions.php");

   $user_data = check_login($con);

   if ($_SERVER['REQUEST_METHOD'] == "POST") {
       $job = $_POST['job'];
   }
?>


<!DOCTYPE html>
<html>
<head>
    <title> NetPlat </title>
</head>
<body>
    <a href="login.php">
        <button id="button">Logout</button>
    </a><br><br>
    <a href="signup.php">
        <button>Signup Student</button>
    </a>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Surrounding the button markup with a simple if statement using the in_array function to check that the job is allowed, will work.

<?php
if(in_array($job, ['teacher', 'staff', 'principal']))
{
?>
    <a href="signup.php">
        <button>Signup Student</button>
    </a>
<?php
}
?>

The above will only output the button html if the value of $job is found in the array.

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!