php echo 为什么输出不出来?

<html>
<body>
<form action=<?echo $PHP_SELF?>>
name:<input type="text" name="name"> 
<input type="submit" name="send" value="say to you"><br>
say:<input type="text" name="message" size="80"> 
</form>
<?php
$name=htmlspecialchars($name);
$message=htmlspecialchars($message);
$header="<html><head><meta http-equiv=\"refresh\" content=\"3\">".
"<meta name=\"robots\" content=\"noindex\"></head>".
"<body bgcolor=\"#000000\" text=\"red\">\n";
$footer="</body></html>";
$message_array=file("message.html");
for($counter=1;$counter<20;$counter++)
$oldmessage.=$message_array[$counter];
$thetime=date("H:i");
$new_message="<b><i>$name</i></b>"."<font size=\"2\">($thetime)</font>:$message<br>\n";
$open_file=fopen("message.html","w");
fputs($open_file,$header);
fputs($open_file,stripcslashes($new_message));
fputs($open_file,$oldmessage);
fputs($open_file,$footer); echo $name; echo $message;
fclose($open_file);

?>
</body>
</html>

从PHP4开始,要用$_REQUEST["name"]获取提交的参数,你的代码在PHP3中没问题,但在PHP4和PHP5中, $name没有赋值,所以不能输出。

改成这样:

<html>
<body>
<form action=<?echo $PHP_SELF?>>
name:<input type="text" name="name">
<input type="submit" name="send" value="say to you"><br>
say:<input type="text" name="message" size="80">
</form>
<?php
$name=htmlspecialchars($_REQUEST["name"]);
$message=htmlspecialchars($_REQUEST["message"]);
$header="<html><head><meta http-equiv=\"refresh\" content=\"3\">".
"<meta name=\"robots\" content=\"noindex\"></head>".
"<body bgcolor=\"#000000\" text=\"red\">\n";
$footer="</body></html>";
$message_array=file("message.html");
for($counter=1;$counter<20;$counter++)
$oldmessage.=$message_array[$counter];
$thetime=date("H:i");
$new_message="<b><i>$name</i></b>"."<font size=\"2\">($thetime)</font>:$message<br>\n";
$open_file=fopen("message.html","w");
fputs($open_file,$header);
fputs($open_file,stripcslashes($new_message));
fputs($open_file,$oldmessage);
fputs($open_file,$footer); echo $name; echo $message;
fclose($open_file);

?>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网