简体   繁体   English

如何防止用户删除源代码中的display:none?

[英]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.

相关问题 如何防止用户访问其他用户记录? - How do I prevent users from accessing other users records? 如何防止用户使用用于在 Web 应用程序中下载 pdf 文件的 PHP 下载选项下载源代码文件? - How to prevent users from downloading source code files using the PHP download option I have for downloading pdf files in my web application? 如何防止foreach语句删除我的小数? - How do I prevent foreach statement from removing my decimals? 如何防止用户将此表格提交为空白? - How do I prevent users from submitting this form blank? 如何防止登录用户访问登录页面? - how do i prevent logged in users from accessing the login page? 如何防止其他用户像其他用户一样劫持HTTP请求有效负载? - How do I prevent other users from hijacking the HTTP request payload as other users? 在CakePHP中添加“ onmouseover”事件时,如何防止$ html-link()删除单引号? - How do I prevent $html-link() from removing the single quotes when adding an 'onmouseover' event in CakePHP? 如何从网页中获取源代码? - How do I get source code from a webpage? 如何防止用户从损坏的会话中“返回”页面? - How do I prevent users from being able to “back” into page from a destroyed session? PHP:允许为用户上传.php文件,如何防止它们运行? - PHP: allowing upload of .php files for users, how do I prevent them from running?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM