-2

I have a table with add, edit, delete options. Now I want to hide divs with buttons for not logging users.

Or maybe I should make a deactivated buttons for not loggin users?

2
  • Please could you post your current code so that we can see what div's you are trying to hide?
    – MikeyBunny
    Oct 30, 2017 at 9:54
  • 1
    You should provide more details about your case. I assume you are using php because you tagged the question as such. However are you using vanilla php or are you using a framework. It's important to know. Oct 30, 2017 at 9:57

2 Answers 2

1

when user login then you have session like

$_SESSION['email']=$email;

then used this code

<?php
if(isset($_SESSION['email']))
{
   echo "<div>any text</div>";
}
?>

do some effort to write the code

0

Depending on how your site works there are two possible solutions that I can think of.

USE PHP

If the user is logged in then use:

<?php
if ($logged_in) {
?>
<div>Your text here</div>
<?php
}
?>

NOTE: You do not need to use "echo" or "print" if you close and open your PHP tags between the "if" as shown below. This can make the HTML part of the much easier to read and write.

USE JAVASCRIPT

If the page does not reload when the user logs in then you will need to use Javascript to hide and show the DIV using something like:

var x = document.getElementById("myDIV");
if (x.style.display === "none") {
    x.style.display = "block";
} else {
    x.style.display = "none";
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.