提问人: 提问时间:9/5/2020 更新时间:9/5/2020 访问量:40
使用输入用 PHP 编辑 Txt 文件?
Editing a Txt File with PHP using inputs?
问:
我想编写一个可以在服务器上编辑简单文本文件的 Web 应用程序。用户将字符串写入表单,然后按输入(按钮)。该文件应该已更改,但它不起作用。
我的HTML;
<form name="form" action="" method="post">`
<input type="text" id="msg" name="msg" placeholder="Enter message...">
</form>
<input type="submit" name="send" value="Send">
我的PHP:
<?php
if(isset($_POST['send'])){
$chatfile = fopen("chat.txt", "w");
$message = $_POST['msg'];
fwrite($chatfile, $message);
fclose($chatfile);
}
?>
这一切都在一个文件中。
答: 暂无答案
评论
<input type="submit" name="send" value="Send">
form
id
file_put_contents('chart.txt', $_POST['msg']);