[英]How do I prevent users from removing display:none in source code?
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. 使用一些if / else PHP语句,我可以显示或隐藏一些div,具体取决于用户正在检出的配置文件页面是否属于该用户。
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 问题是,即使我要检出的个人资料不属于我,如果我使用Google网站站长工具检查了该元素并删除了
style="display:none"
the div becomes visible again. div 再次可见。
How could I prevent that? 我该如何预防?
just remove the else
part 只需删除
else
部分
<?php
if ($uid == $id) {
?>
<div id="block_user"></div>
<?php } ?>
If you want to hide stuff for real you have to dynamically create it within the PHP code... Such as : 如果要隐藏真实的东西,则必须在PHP代码中动态创建它,例如:
<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. 我想您已经在这样做了,但是如果您不想显示它,就不要打印出来。
instead of hiding the div, remove the div element which you don't want to show. 而不是隐藏div,请删除您不想显示的div元素。
$id = $_SESSION['id'];
if ($uid == $id)
{
?>
<div id="block_user"></div>
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.