所以这是一个简短的故事:我有一个包含用户输入的评论框(我想就像任何常规评论框一样)。我想将此用户输入发送到日志文件。问题是,这没有发生。
这就是我所拥有的:
if (isset ($_REQUEST['saving'])) {
$saving = $_REQUEST['saving'];
if ($saving ==1) {
$comments = $_POST['comment'];
$file = "logfile.txt";
$fp = fopen($file, "w") or die ("Couldn't open $file for writing!");
fwrite($fp, $comment) or die ("Couldn't write values to file!");
fclose($fp);
echo "Saved to $file successfully!";
}
}
它发送的信息来自:
<textarea name="comment" cols="80" rows="10">
<?php echo $comment; ?>
</textarea><br>
其中 $comment 是用户输入。我没有收到任何错误消息,但是当我打开 logfile.txt 时,它是空的。
任何帮助都会很棒。我真的被困住了。提前感谢所有建议:-)