1

With some if/else PHP statement, I can show or hide some divs depending on if the profile page being checked out by a user belongs to that user or not.

For instance,

$id = $_SESSION['id'];
if ($uid == $id)
{
?>
<div id="block_user"></div>
<?php }
else { ?>
<div id="block_user" style="display:none"></div>
<?php
}  ?>

The issue is even if the profile I'm checking out doesn't belong to me, if I inspect the element with Google webmaster tool, and remove

style="display:none"

the div becomes visible again.

How could I prevent that?

3 Answers 3

3

just remove the else part

<?php
if ($uid == $id) {
?>
<div id="block_user"></div>
<?php } ?>
1
  • I will, i have to wait 10 minutes though
    – Caro_deb
    Jul 5, 2013 at 11:22
1

If you want to hide stuff for real you have to dynamically create it within the PHP code... Such as :

<php

    if ($uid == $id){
     echo '<div id="block_user"></div>';
    }

?>

which I guess you already are doing but simply dont print it out if you dont want to show it.

1

instead of hiding the div, remove the div element which you don't want to show.

$id = $_SESSION['id'];
if ($uid == $id)
 {
  ?>
  <div id="block_user"></div>
<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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