【问题标题】:comment system using php inside the body , and there is error on the result在正文中使用php的评论系统,结果有错误
【发布时间】:2013-05-12 14:12:51
【问题描述】:

我在记事本中写下这段代码,并保存在 .html 范围内, 我想设计一个带有数据库(即记事本)的简单评论系统来保存 cmets,但是当我单击提交按钮时,它会出现特定命令中的错误,即 $_SERVER['PHP_SELF']。你能帮助我吗 ?

<html>
<body>
<div class ="forumform">
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
name: <input type=text name="name" id="name">
comment: <input type=text name="commentcontent" id="commentcontent">
<button type="submit" value="submit" name="submit" class="btn">submit</button>
</form>

</body>
</html>

【问题讨论】:

  • 你试过不使用短标签吗? &lt;?php echo 而不是 &lt;?=
  • 仅供参考,如果不受 htmlspecialchars() 保护,请勿使用 $_SERVER['PHP_SELF'] 易受 XSS 攻击,如果您想回帖,请使用 action=""

标签: php html database wamp notepad++


【解决方案1】:

你说的是:"i am wrinting this code below in notepad and i saved in .html extent"

&lt;?=$_SERVER['PHP_SELF']?&gt; 这样的PHP 命令/脚本只能在带有.php 意图的文件中运行!!不在 HTML 上。

您应该将文件的扩展名更改为.php

【讨论】:

    【解决方案2】:

    您正在使用 php echo 快捷方式,确保在您的 php.ini 文件 serach 中为此 short_open_tag 启用它并启用它或简单地使用 &lt;?php echo .... ?&gt; 而不是 &lt;?= ... ?&gt;

    【讨论】:

      猜你喜欢
      • 2013-02-25
      • 2016-05-02
      • 2014-02-26
      • 1970-01-01
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多