当我尝试进入
<script type="text/javascript" >
alert("hello");
</script>
在我的PHP页面上的注释框中,我没有收到警告框。我在文本文件中而不是在网页上看到了脚本。由于某种原因,该代码<script>
无法执行。我在所有浏览器上都启用了活动脚本和JavaScript。
My PHP code:
<?php //CFPcomments.php
include_once 'CFPheader.php';
if (isset($_POST['content']))
{
$fp = fopen('comments.txt', 'a');
fwrite($fp, $_POST['content'] . "<br />");
fclose($fp);
}
echo nl2br(file_get_contents('comments.txt'));
echo <<<_END
<h3>Post comment</h3>
<form action='CFPcomments.php' method='post'>
<textarea name='content' rows ='3' cols='100'></textarea>
<br/>
<input type='submit' value='Post' />
</form>
_END;
?>
奇怪的。我知道它可以工作了,不知道为什么。
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
alert("hello");
</script>
</head>
<body>
</body>
</html>
当我输入此内容时,它似乎可以正常工作
有人知道为什么吗??很混乱。
我为内容分配了一个变量,然后在PHP代码中显示了该变量。现在可以了。
<?php //CFPcomments.php
include_once 'CFPheader.php';
setcookie("username", $GLOBALS['user'], time()+3600);
setcookie("password", $GLOBALS['pass'], time()+3600);
if (isset($_POST['content']))
{
$fp = fopen('comments.txt', 'a');
fwrite($fp, $_POST['content'] . "<br />");
fclose($fp);
}
$comment = file_get_contents('comments.txt');
echo <<<_END
<h3>Post comment</h3>
'$comment'
<form action='CFPcomments.php' method='post'>
<textarea name='content' rows ='3' cols='100'></textarea>
<br/>
<input type='submit' value='Post' />
</form>
_END;
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句