我需要逃避这段代码吗? [英] Do I need to escape this code?
问题描述
嗨!
最近你们给了我一些好的建议后,我又回来了:o)
On在我的网站上,我想显示一个注销图标,下面有一些文字
,(注销),点击后会结束一个会话。
这是我用于图标的简单代码:
< a href ="<?php echo $ _SERVER [ '' PHP_SELF '']; ?>?action = log_out">
< img border =" 0" SRC ="图像/ logout.gif"宽度= QUOT; 74" height =" 74">< p
style =" text-align:center">
一切正常,当点击,会话结束,
用户返回我网站的主页。
现在很复杂,(好吧)我,无论如何),有点;我只想在用户实际登录时显示
''注销''图标。
所以,我一直在使用isset确定会话状态:
<?php if(isset($ _ SESSION [''user''])){?>
< ; a href ="<?php echo $ _SERVER [''PHP_SELF'']; ?>?action = log_out">
< img border =" 0" SRC ="图像/ greenround.PNG"宽度= QUOT; 74" height =" 74">< p
style =" text-align:center">
<?php}?>
现在 - 这只是部分有效;是的,图标仅在
用户登录时显示 - 这很酷。但是,当点击它时它不会做任何事情!
我想我应该在某个地方逃避一些代码,但我不能工作
out。这让我感到很沮丧!!
关于这个新手哪里出错的指导?
谢谢!
Rod。
Hi!
After you all gave me some good advice recently, I''m back for more :o)
On my web site, I want to display a ''log out'' icon with some text
underneath, ("Log out"), which, when clicked, will end a session.
This is the simple code I''m using for the icon:
<a href="<?php echo $_SERVER[''PHP_SELF'']; ?>?action=log_out">
<img border="0" src="images/logout.gif" width="74" height="74"><p
style="text-align: center">
This all works fine and, when clicked, the session is ended and the
user returns to my web site''s home page.
Now''s the complicated, (Well for me, anyway), bit; I only want to show
the ''log out'' icon when the user is actually logged in.
So, I''ve been using isset to determine the session state:
<?php if (isset($_SESSION[''user''])) {?>
<a href="<?php echo $_SERVER[''PHP_SELF'']; ?>?action=log_out">
<img border="0" src="images/greenround.PNG" width="74" height="74"><p
style="text-align: center">
<?php }?>
Now - this only partially works; yes, the icon is only shown when the
user is logged in - which is cool. However, when clicked it doesn''t do
anything!
I think I should be escaping some code somewhere but I can''t work it
out. And it''s frustrating me!!
Any guidance on where this newbie is going wrong?
Thanks!
Rod.
推荐答案
_SERVER [''PHP_SELF'']; ?>?action = log_out">
< img border =" 0" SRC ="图像/ logout.gif"宽度= QUOT; 74" height =" 74">< p
style =" text-align:center">
一切正常,当点击,会话结束,
用户返回我网站的主页。
现在很复杂,(好吧)我,无论如何),有点;我只想在用户实际登录时显示
''注销''图标。
所以,我一直在使用isset确定会话状态:
<?php if(isset(
_SERVER[''PHP_SELF'']; ?>?action=log_out">
<img border="0" src="images/logout.gif" width="74" height="74"><p
style="text-align: center">
This all works fine and, when clicked, the session is ended and the
user returns to my web site''s home page.
Now''s the complicated, (Well for me, anyway), bit; I only want to show
the ''log out'' icon when the user is actually logged in.
So, I''ve been using isset to determine the session state:
<?php if (isset(
_SESSION [''user''])){?> ;
< a href ="<?php echo
_SESSION[''user''])) {?>
<a href="<?php echo
_SERVER [''PHP_SELF'']; ?>?action = log_out">
< img border =" 0" SRC ="图像/ greenround.PNG"宽度= QUOT; 74" height =" 74">< p
style =" text-align:center">
<?php}?>
现在 - 这只是部分有效;是的,图标仅在
用户登录时显示 - 这很酷。但是,当点击它时它不会做任何事情!
我想我应该在某个地方逃避一些代码,但我不能工作
out。这让我感到很沮丧!!
关于这个新手哪里出错的指导?
谢谢!
Rod。
_SERVER[''PHP_SELF'']; ?>?action=log_out">
<img border="0" src="images/greenround.PNG" width="74" height="74"><p
style="text-align: center">
<?php }?>
Now - this only partially works; yes, the icon is only shown when the
user is logged in - which is cool. However, when clicked it doesn''t do
anything!
I think I should be escaping some code somewhere but I can''t work it
out. And it''s frustrating me!!
Any guidance on where this newbie is going wrong?
Thanks!
Rod.
这篇关于我需要逃避这段代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!