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?

4

3 回答 3

3

just remove the else part

<?php
if ($uid == $id) {
?>
<div id="block_user"></div>
<?php } ?>
于 2013-07-05T11:14:57.183 回答
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.

于 2013-07-05T11:17:02.410 回答
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 } ?>
于 2013-07-05T11:19:04.537 回答