Session variable to hide/unhide button

I wish to use a session variable to hide a button that is in a column of 8 buttons. I have tried the following PHP code:

        <?PHP
            if($_SESSION['user_pkey']==1){
        ?>
              <button class = "btn btn-info btn mt-2 my_specialbtn btn-lg" onclick="document.location='volscontactinfodirectory.php'">Add Database User</button>
        <?PHP }
        ?>

I wan t this button to display if ‘pkey’ is 1 else hide it.

How do I do this?

Thanks in advance

Why don’t you just do in JavaScript?

var specialBtn = document.querySelector('.my_specialbtn');

specialBtn.addEventListener('click', function() {
  if (specialBtn.style.display === 'none') {
    specialBtn.style.display = 'block';
  } else {
    specialBtn.style.display = 'none';
  }
});

Sponsor our Newsletter | Privacy Policy | Terms of Service