php帮助用cookie隐藏导航
我的导航上有这些选项卡:
<li<?php if ($thisPage=="Customers") echo " class=\"current\""; ?>><a href="/customers/">Customers</a></li>
<li<?php if ($thisPage=="Trunks") echo " class=\"current\""; ?>><a href="/trunks/">Trunks</a></li>
<li<?php if ($thisPage=="Settings") echo " class=\"current\""; ?>><a href="/settings/">Settings</a></li>
并且我只想在管理员登录时显示它们:
if ($_COOKIE['custid'] == "admin") {
echo "Customers";
echo "Trunks";
echo "Settings";
}
如何组合这两个脚本???
I have these tabs on my navigation:
<li<?php if ($thisPage=="Customers") echo " class=\"current\""; ?>><a href="/customers/">Customers</a></li>
<li<?php if ($thisPage=="Trunks") echo " class=\"current\""; ?>><a href="/trunks/">Trunks</a></li>
<li<?php if ($thisPage=="Settings") echo " class=\"current\""; ?>><a href="/settings/">Settings</a></li>
and I only want to show them when admin is logged in:
if ($_COOKIE['custid'] == "admin") {
echo "Customers";
echo "Trunks";
echo "Settings";
}
How can I combine the two of these scripts???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将“cookie 中的管理”问题视为一个单独的问题...
PHP 的内联语法比在 html 中使用 {} 和 echo 好得多
Treating the "admin in cookie" issue as a separate issue...
PHP's inline syntax is much nicer than using {} and echos inside html
很简单,把它放在另一个里面......
Pretty simple, put it inside the other one...
不太确定你的意思,但是:
我同意帖子本身评论中的@webdestroya;您应该使用会话或类似的方式而不是 cookie 来验证管理员状态。我只是为了示例而没有在这里更改它。
Not exactly sure what you mean, but:
And I agree with @webdestroya in the comments on the post itself; you should use a session or similar instead of a cookie to verify administrator status. I just didn't change it here for the sake of the example.